This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace PureIO { | |
/* | |
C# does not have proper sum types. They must be emulated. | |
This data type is one of 4 possible values: | |
- WriteOut, being a pair of a string and A | |
- WriteErr, being a pair of a string and A | |
- readLine, being a function from string to A |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lan.dk.podcastserver.utils.multipart; | |
import lan.dk.podcastserver.utils.MimeTypeUtils; | |
import org.apache.commons.lang3.StringUtils; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import javax.servlet.ServletOutputStream; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Control.Monad.Trans (lift) | |
import Control.Parallel (par, pseq) | |
import Data.Text.Lazy (pack) | |
import System.Random (StdGen, newStdGen, random) | |
import Web.Scotty (get, scotty, text) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tenemos una lista ordenada (por :priority) de objetos. debe poder accederse por índice (lo que al menos en clj, descarta la posibilidad de usar un set). | |
puede haber múltiples objetos con el mismo valor :priority. | |
[{:priority 1} {:priority 1} {:priority 3} {:priority 3} {:priority 3} {:priority 5} {:priority 5} {:priority 8} {:priority 8} {:priority 8}] | |
en mi dominio, cada objeto tiene más claves aparte de :priority, pero son irrelevantes en este problema. | |
lo que deseamos es un método que nos dé el índice de acceso de un elemento al azar, un azar influido por las prioridades. | |
digamos que dos objetos con la misma :priority tienen elegibilidad equiprobable, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Se define en un modulo una funcion polimorfica en funcion del tipo | |
;; de los *dos argumentos* | |
(ns modulo1) | |
(defmulti write (fn [writer data] [(type writer) (:type data)]) | |
;; En otro modulo que importa la definicion anterior generica de write | |
(ns modulo2 (require modulo1)) | |
(defmethod modulo1/write [java.io.FileWriter :user] [writer user] | |
(comment codigo especifico usando el FileWriter y teniendo en cuenta | |
que los datos son del tipo :usuario)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module JJFW where | |
import Data.Map hiding (map) | |
import Data.Array.IO | |
import Control.Monad (forM_) | |
import System.Time | |
import System.IO | |
type Edge = (Int,Int) | |
type EdgeCost = (Edge,Int) | |
type IOAcc = IOUArray (Int,Int) Int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Warshall where | |
import Data.Char ( isAlpha ) | |
import Data.List ( nub, sort ) | |
import System.Environment ( getArgs ) | |
import Text.Parsec | |
import Text.Parsec.String | |
import Text.Printf ( printf ) | |
type Vertex a = a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import grails.plugin.spock.UnitSpec; | |
import org.codehaus.groovy.runtime.ArrayUtil; | |
import org.codehaus.groovy.runtime.callsite.CallSite; | |
import org.spockframework.runtime.model.FeatureMetadata; | |
import org.spockframework.runtime.model.FieldMetadata; | |
import org.spockframework.runtime.model.SpecMetadata; | |
@SpecMetadata(filename="PrincipalSpec.groovy") | |
public class PrincipalSpec extends UnitSpec | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; Copyright (c) Rich Hickey. All rights reserved. | |
; The use and distribution terms for this software are covered by the | |
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php) | |
; which can be found in the file CPL.TXT at the root of this distribution. | |
; By using this software in any fashion, you are agreeing to be bound by | |
; the terms of this license. | |
; You must not remove this notice, or any other, from this software. | |
;dimensions of square world |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns rand-tree) | |
(defn seed [] | |
(let [r #(when (zero? (rand-int 2)) seed)] | |
{:left (r) | |
:right (r)})) | |
(def seed? fn?) | |
(def leaf? nil?) | |
(def branch? map?) |
NewerOlder