hslisp is LISP variant coded in Haskell.
hslisp is (partially) lazy-evaluted pure functional programming language.
Note there is no way to perform I/O in this language. Seperating pure computations and impure computations(I/O) appropriately is very complex problem. Think about Monad system in Haskell, and I have no ability to apply that in my language.
-
Reverse alphabet list
(reverse ['a' ~ 'z'])
(reverse function is defined in stdlib.hl)
→['z' 'y' 'x' 'w' 'v' 'u' 't' 's' 'r' 'q' 'p' 'o' 'n' 'm' 'l' 'k' 'j' 'i' 'h' 'g' 'f' 'e' 'd' 'c' 'b' 'a']
-
Solution for Project Euler Problem No 1.
(sum (unique (++ [3 6 ~ 999] [5 10 ~ 999])))
→ 233168
- Execute with no program argument : run REPL without any task.
- Execute with arguments : Load files enumerated in program arguments, and run REPL.
For example, runhaskell main.hs stdlib.hs
, loads stdlib.hs and runs REPL.
Of course, instead of runhaskell, you can compile and run this with Haskell compiler such as ghc.
- Floating point number literal. Uses
Double
type in Haskell.
- Integral number literal. Uses
Integer
type in Haskell.
- Boolean literal. Uses
Bool
type in Haskell.
- Character literal. Uses
Char
type in Haskell.
- String literal. Almost same syntax with C-string.
- This is actually a Data List of Chars.
- Syntactic sugar for
(quote <Expr>)
- Finite data list. All the elements are evaluated when list is evaluated.
- List can contain all possible types in this language.
- Containing values of different types in a single list is also granted.
- Finite Range list. Only begin expression and end expression are evaluted when list is evaluted.
- Begin expression type and end expression type must be same.
- Possible types for begin/end expresson : Integer, Real, Char
- Finite Range list. It's almost same with above one, but this has two begin expressions.
- For instance, [1 3 ~ 9] equals to [1 3 5 7 9].
- Only two begin expressions and end expression are evaluted when list is evaluted.
- Infinite Range list. It's almost same with Finite Range list, but this has no end expression, so infinite.
- Only begin expression is evaluted when list is evaluted.
- Infinite Range List. It's almost same with above one, but this has two begin expressions.
- Only two begin expressions are evaluted when list is evaluted.
- Syntactic sugar for
(lambda (<Symbol>...) <Expr>)
- Function Call. Call arguments are not evaluted in this moment.
- Defines constant to global context.
- Example :
(define ten 10)
- Returns anonymous function.
- Syntactic sugar for
(define <Symbol> (lambda (<Symbol>...) <Expr>))
- Example :
(defun add (x y) (+ x y))
- Defines local constants and evalutes last argument, and returns it.
- Example :
(let (a 10) (b 15) (* a b))
- Returns sum of arguments.
- Return type is same with type of arguments.
- Only Integer and Real type are allowed for argument type.
- Every arguments type must be same.
- Returns (First argument) - (Second argument).
- Return type is same with type of arguments.
- Only Integer and Real type are allowed for argument type.
- Every arguments type must be same.
- Returns product of arguments.
- Return type is same with type of arguments.
- Only Integer and Real type are allowed for argument type.
- Every arguments type must be same.
- Returns (First argument) / (Second argument).
- Return type is same with type of arguments.
- Only Integer and Real type are allowed for argument type.
- Every arguments type must be same.
- Returns (First argument) % (Second argument). (modulo)
- Return type is same with type of arguments.
- Only Integer and Real type are allowed for argument type.
- Every arguments type must be same.
- Returns
true
(boolean) if all the arguments are same, otherwisefalse
. - Only Integer, Real and Boolean type are allowed for argument type.
- Every arguments type must be same.
- Returns
false
(boolean) if all the arguments are same, otherwisetrue
. - Only Integer, Real and Boolean type are allowed for argument type.
- Every arguments type must be same.
- Returns
true
(boolean) if (First argument) is greater than (Second argument), otherwisefalse
. - Only Integer and Real type are allowed for argument type.
- Every arguments type must be same.
- Returns
true
(boolean) if (First argument) is greater than or equal to (Second argument), otherwisefalse
. - Only Integer and Real type are allowed for argument type.
- Every arguments type must be same.
- Returns
false
(boolean) if (First argument) is greater than (Second argument), otherwisetrue
. - Only Integer and Real type are allowed for argument type.
- Every arguments type must be same.
- Returns
false
(boolean) if (First argument) is greater than or equal to (Second argument), otherwisetrue
. - Only Integer and Real type are allowed for argument type.
- Every arguments type must be same.
- Returns true(boolean) if all the arguments are
true
, other wisefalse
. - Only Boolean type is allowed for argument type.
- Returns true(boolean) if one of the arguments is
true
, otherwisefalse
. - Only Boolean type is allowed for argument type.
- Returns (Second argument) if (First Argument) is true, otherwise (Third argument).
- Type of (First Argument) must be boolean.
- Returns first element of data list(First Argument).
- Only first element of list is evaluted, so
(head [1 ~ ])
returns 1 without any overhead.
- Returns tail(List except first element) of data list(First Argument).
- Returns list concatenated (First Argument) and (Second Argument), where both are data list.
- Returns length of (First Argument, data list).
- Nothing is evaluted, and returns first argument.
- Evalutes quoted expression (First Argument), and returns it.
- Feeds data list (Second Argument) elements as argument to function (First Argument).