Macro shorthands¶
Whilst in Lambda calculus there is no limit on how many or what kind of forms
one can create, there is a set of common forms useful for constructing Lambda
expressions. Named forms are provided as macros in Hy based calchylus
module and they serve for shorthands when coding in Lambda calculus. Named forms
are useful in explaining Lambda calculus and they make expressions more compact,
readable, and understandable.
This is the list of the all available macros for Lambda forms in calchylus
module:
Basic constructors
APP
- an applicationCONST
- a constantIDENT
- an identity
Boolean constructors
TRUE
- an arbitrary tautologyFALSE
- an arbitrary contradiction
Logical connective constructors
- Unary
NOT
- a negation
- Binary
AND
- a conjuctionOR
- a disjunctionXOR
- an exclusive disjunctionIMP
- a material implicationEQV
- an equivalence / a material biconditional
Structural constructors
COND
- a condition block for flow controlLET
- introduce a variable/variables with a value / values, last term is the function body!LET*
- same as LET, but consequencing variables can use former variables in the bodyDO
- do things in sequence, similar toLET*
, but except setters are disclosed
2-tuple constructor
PAIR
- a nested ordered pairHEAD
- a head of the pairTAIL
- a tail of the pair
List constructors
LIST
- create list with sequential items, generates nested pairs from given termsPREPEND
- prepend to the beginning of the listAPPEND
- append to the end of the listFIRST
- the first item of the listSECOND
- the second item of the listLAST
- the last item of the listLEN
- length of the listEMPTY?
- is given term an empty list?NIL?
- is given term nil?- Internal
NIL
- a nil for the empty set∅
- an empty set
Church numerals
NUM
- a Church numeral generatorZERO
- the number zero, same asFALSE
- numerals from one to ten
ONE
TWO
THREE
FOUR
FIVE
SIX
SEVEN
EIGHT
NINE
TEN
NUM?
- is given term a number, unary predicate checker for Church numbers
Number equivalence
ZERO?
- is number zero?EQ?
- are two numbers equal?LEQ?
- is number a equal or smaller than b?GEQ?
- is number a equal or greater than b?LE?
- is number a less than b?GE?
- is number a greater than b?
Arithmetic constructors
SUCC
- a successor of a numberPRED
- a predecessor of a numberSUM
- a summa of two numbersSUB
- a substraction of two numbersPROD
- a product of two numbersEXP
- the nth power of number x
Recursive constructors
SELF
- a self applicationYCOMB
- an Y combinator
Sample mathematical functions
SUMMATION
- the nth triangular numberFACTORIAL
- a product of numbers up to nFIBONACCI
- the nth Fibonacci number