Pizarnik is a stack-based, concatenative language with extensible cases and evocative syntax for pattern-matching.
type B = {`t ⊕ `f};
if : a b `t -- a
:= [ `t⁻¹ drop ]
else : a b `f -- b
:= [ `f⁻¹ nip ]
choice : a a B -- a
:= [ { if & else } ]
@i prelude/fn
%-
type List a = { `nil ⊕ List(a) a `cons };
type NE a = { List(a) a `cons };
head : NE(a) -- a
:= [ { `cons⁻¹ nip } ]
foldr : [ a b -- b ] b List(a) -- b
:= [ { `nil⁻¹ nip
& `cons⁻¹ [dup] dip3 rotl [rot [rot $] dip swap] dip foldr } ]
The same foldr
works on nonempty lists and lists; head
only works on nonempty lists.
&
(with) forms or-patterns, viz.
@i prelude/fn
%-
type Ord = {`lt ⊕ `eq ⊕ `gt};
gt : Ord -- Bool
:= [ { { `lt⁻¹ & `eq⁻¹ } False & `gt⁻¹ True } ]