Concatenative topics
Concatenative meta
Other languages
Meta
The following demonstrates a concatenative programming capable of running Factor's implementation of the Y combinator, in Modal.
<> (?0 ?1 >> `?:) (?: >>) <> (>> +) (>> `+) <> (>> -) (>> `-) <> (>> *) (>> `*) <> (>> >) (>> `>) <> (>> &) (>> `&) <> (>> =) (>> `=) <> (>> lit ?x) (?x >>) <> (?x ?y >> swap) (?y ?x >>) <> (?x >> dup) (?x ?x >>) <> (?x >> drop) (>>) <> (() >> call) (>>) <> (?. >> call) (>> ?.) <> (?x ?. >> dip) (>> ?. lit ?x) <> (?x ?. >> curry) ((?x ?.) >>) <> (?. ?x >> compose) ((?. ?x call) >>) <> (1 ?t ?f >> if) (?t >> call) <> (0 ?t ?f >> if) (?f >> call) <> (() ?x #snoc) ((?x)) <> (?. ?x #snoc) ((?. ?x)) <> (>> : ?x) (?x () ..) <> (?x ?. .. ;) ([edit>>] <> (>> ?x) (>> ?.) [/edit>>] >>) <> (>> [) (1 () ..) <> (.. [) (0 () ..) <> (0 ?x .. ]) (?x #snoc ..) <> (1 ?x .. ]) (?x >>) <> (?: #print) (?:) <> (.. .") (() ...") <> (..." ") (#snoc . #snoc ..) <> (..." ?x) (?x #snoc ...") <> (>> .) (#print >>) <> (>> .s) (() >>.s) <> (?x () >>.s) ((?x) >>.s) <> (?x ?. >>.s) ((?x ?.) >>.s) <> (?. >>.s) ((?.\n) #print ?. >>) <> ([edit>>]) (>< (>> ?x)) <> ([/edit>>]) (<> (>> ?x) (?x >>)) <> ([edit..]) (>< (.. ?x)) <> ([/edit..]) (<> (.. ?x) (?x #snoc ..)) [/edit..] [/edit>>] >> : Y [ [ [ dup call call ] curry ] ] dip compose dup call ; : almost-fac [ [ dup 1 - ] ] dip [ * ] compose compose [ [ dup 0 = [ drop 1 ] ] ] dip [ if ] curry compose ; 5 [ almost-fac ] Y call .s
This revision created on Wed, 8 May 2024 17:06:00 by neauoire