Front Page All Articles Recent Changes Random Article

Contents

Concatenative language

  • ACL
  • Ait
  • Aocla
  • Breeze
  • Callisto
  • Cat
  • Cognate
  • colorForth
  • Concata
  • CoSy
  • Deque
  • DSSP
  • dt
  • Elymas
  • Enchilada
  • ETAC
  • F
  • Factor
  • Fiveth
  • Forth
  • Fourth
  • Freelang
  • Gershwin
  • hex
  • iNet
  • Joy
  • Joy of Postfix App
  • kcats
  • Kitten
  • lang5
  • Listack
  • LSE64
  • Lviv
  • Meow5
  • min
  • Mirth
  • mjoy
  • Mlatu
  • Ode
  • OForth
  • Om
  • Onyx
  • Plorth
  • Popr
  • Porth
  • PostScript
  • Prowl
  • Quest32
  • Quackery
  • r3
  • Raven
  • Retro
  • RPL
  • SPL
  • Staapl
  • Stabel
  • Tal
  • Titan
  • Trith
  • Uiua
  • Worst
  • xs
  • XY
  • 5th
  • 8th

Concatenative topics

  • Compilers
  • Interpreters
  • Type systems
  • Object systems
  • Quotations
  • Variables
  • Garbage collection
  • Example programs

Concatenative meta

  • People
  • Communities

Other languages

  • APL
  • C++
  • Erlang
  • FP trivia
  • Haskell
  • Io
  • Java
  • JavaScript
  • Lisp
  • ML
  • Oberon
  • RPL
  • Self
  • Slate
  • Smalltalk

Meta

  • Search
  • Farkup wiki format
  • Etiquette
  • Sandbox

Modal/Embedded Concatenative Language

The following demonstrates a concatenative programming capable of running Factor's implementation of the Y combinator.

<> (?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 03:36:55 by CapitalEx (Add cat lang embedded in modal.)

Latest Revisions Edit

All content is © 2008-2024 by its respective authors. By adding content to this wiki, you agree to release it under the BSD license.