Skip to content

Instantly share code, notes, and snippets.

View karahobny's full-sized avatar

squire of the λ-calculus karahobny

View GitHub Profile
@karahobny
karahobny / lazar-example.scm
Created May 13, 2018 17:18
example of function definitions with lazar
;; α | Any | a' => literally any type
;; Num { ℕ | ℤ | ... } => numerical tower, natural numbers, integers etc.
;; Fn => procedure/function
;; Ø? (null list predicate), Ø (null list), ¬ (negation, not)
;; hd (car = first of list), tl (cdr = all but first of list), :: (cons operator)
(define/c (foldl ((f : Fn) (n : α) (xs : List)) -> α)
(case-with || (Ø? xs) => n
|| _ => (foldl f (f n (hd xs)) (tl xs))))