Concatenative language
Concatenative topics
Concatenative meta
Other languages
Meta
Quotations are the general term for anonymous functions or lambdas. They denote a snippet of code which can be executed later. Their exact syntax varies by language. For example, [[Factor]] denotes quotations using square-brackets. Whereas, [[Tal]] and [[Postscript]] denote them using curly-brackets. Regardless of syntax, they are core to constructing higher-order functions in [[Concatenative language|concatenative languages]]. === Higher-Order Function === A higher-order function is an operation that utilize other functions as inputs or create new functions as outputs. This feature is leverage by a core utility of concatenative programming: combinators. They enable a programmer to [[Concatenative language/Name code not values|name code not values]]. ==== Factor ==== [factor{{ 1 2 3 4 } [ sq ] map }] ==== Kitten ==== [kitten{// [1, 4, 9, 16] [1, 2, 3, 4] { dup (*) } map}] ==== Tal ==== Uxntal has no built-in %map%, see [[Tal|implementation]]. [tal{{ 01 02 03 04 } { DUP MUL JMP2r } map}] Uxntal can also quote single opcodes: [{( to quote ) LIT ADD ( to unquote ) #00 STR}] ==== Mirth ==== [mirth{1 2 3 4 L4 [ dup * ] map}] Mirth has syntactic sugar that lets you write a quotation as an argument to the higher-order word, so a more idiomatic way to write this is: [mirth{1 2 3 4 L4 map(dup *)}] ==== Titan ==== Titan does not have a built in %ForAll% function, but it is implemented in %std.quote%. [{[1 2 3 4] [: ×] ∀}]
Describe this revision:
Save