This file contains 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 Main where | |
import Control.Monad | |
import Data.List | |
import Data.Char (intToDigit) | |
perms xs n = do | |
l <- replicateM n xs | |
guard (length l <= n) | |
let z = do x <- [0..(n - 1)] |
This file contains 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
lambda.match> (time (sidelong-count-and-sum (range 100000000))) | |
"Elapsed time: 89361.517429 msecs" | |
[100000000 4999999950000000] | |
lambda.match> (time (reduce #((juxt | |
(partial (fn [x y] (+ x 1)) (first %)) ; count | |
(partial + (second %))) ; sum | |
%2) | |
[1 0] | |
(range 1 100000000))) |
This file contains 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 main | |
import ( | |
"fmt" | |
"github.com/jackpal/bencode-go" | |
"net" | |
"os" | |
"path/filepath" | |
"strconv" | |
"strings" |
This file contains 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
#!/usr/bin/env boot | |
;; | |
;; Threads & concurrency without hardware threads or continuations | |
;; | |
;; Most of this is from the paper "Trampolined Style" by Ganz, Friendman, and Wand | |
;; | |
(defrecord Done [value]) | |
(defrecord Doing [thunk]) |
This file contains 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 DeriveGeneric #-} | |
{-# LANGUAGE DeriveAnyClass #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
module Job where | |
import Data.Serialize (Serialize, encode, decode) | |
import Data.Typeable | |
import GHC.Generics | |
import Control.Monad (join) | |
import qualified Data.ByteString as B |