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 calchylus3
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 calchylus3
module:
Basic constructors
CONST
- a constantIDENT
- an identity
Common combinators
S
- apply x to y in the domain of zK
- take the first, leave the secondK′
- take the second, leave the firstI
- return the given argument aka identity functionB
- composition of the arguments x and y applied to the argument zC
- swaps the arguments y and zW
- duplicates the argument yW′
- append the second argument yW′
- append the first argument xX
- iotaX′
- anti iotaY
- Y-combinatorY′
- anti Y-combinatorΘ
- anti iotaω
- omegaΩ
- big omegaΩ′
- anti big omega
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
- an implicationMIMP
- a material implicationEQV
- an equivalence / a material biconditional, same as xnorNAND
- not a conjuction, all other logic gates are doable with this andXNOR
NOR
- not a disjunctionXNOR
- not an exclusive disjunction, all other logic gates are doable with this andNAND
NIMP
- not an implicationNMIMP
- not a material implicationNEQV
- not an equivalence, same as nor
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 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 listTHIRD
- the third 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 setEMPTY
- 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 numbersMUN
- convert church number to digits
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?LE2?
- is number a less than b?, version 2GE?
- 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 numberFIBONACCI2
- the nth Fibonacci number, version 2