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
sublists :: Int -> [a] -> [[a]] | |
sublists n xs = filter (\x -> length x == n) $ contiguous n xs | |
where | |
contiguous _ [] = [] | |
contiguous n (x:xs) = | |
take n (x:xs) : contiguous n xs |
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
// Y= λf.(λx.f (x x)) (λx.f (x x)) | |
y = f => { | |
const g = x => f(x(x)) | |
return g(g) | |
} | |
// seems equivalent to Z for use in applicative order langs | |
// Y1= λf.(λx. (λy. f (xx) y))(λx. (λy. f (xx) y)) | |
y1 = f => { |
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
// This excludes us from trying to use (Maybe null) sensibly. | |
export type Maybe<T> = T | null | |
export function isJust<T>(x: Maybe<T>): x is T { | |
return x !== null | |
} | |
export function isNothing<T>(x: Maybe<T>): x is null { |
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 DeriveFunctor #-} | |
module Prob where | |
import Control.Monad (forM_) | |
import qualified Data.Map as M | |
import Text.Printf (printf) | |
newtype Prob a = Prob {unProb :: [(a, Double)]} deriving (Functor, Show) |
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 Lib.SubMsg exposing (..) | |
type SubMsg | |
= SubMsgA | |
| SubMsgB |
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
function fib() { | |
var head = 0; | |
var tail = 0; | |
return function() { | |
var res = head + tail; | |
//just for the beginning, so we get 2 rounds with a result of 1 | |
if (!res) { | |
head = 1; |