Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uzimaru0000/ulmus
Ulmus is a Lisp implementation made with Elm
https://github.com/uzimaru0000/ulmus
Last synced: 2 months ago
JSON representation
Ulmus is a Lisp implementation made with Elm
- Host: GitHub
- URL: https://github.com/uzimaru0000/ulmus
- Owner: uzimaru0000
- License: mit
- Created: 2021-06-15T19:31:03.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-06-21T18:38:28.000Z (over 3 years ago)
- Last Synced: 2024-05-18T20:47:59.353Z (8 months ago)
- Language: Elm
- Homepage: https://package.elm-lang.org/packages/uzimaru0000/ulmus/latest/
- Size: 113 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-elm-pltd - ulmus - Ulmus is a Lisp implementation made with Elm. (Languages / Interpreters)
README
# ulmus
Ulmus is a Lisp implementation made with Elm
```elm
import Parser
import Platform exposing (worker)
import Ulmus
import Ulmus.AST as Ulmus exposing (show)
import Ulmus.Parser exposing (parser)eval : String -> Result String AST
eval code =
Parser.run parser code
|> Result.mapError (always "error")
|> Result.andThen (Ulmus.evalAll (Sybl NIL))
|> Result.map Tuple.first-- Value
eval "3" --> Ok (Sybl (Num 3))
eval "3.14" --> Ok (Sybl (Num 3.14))
eval "\"Hello\"" --> Ok (Sybl (Str "Hello"))
eval "nil" --> Ok (Sybl NIL)
eval "t" --> Ok (Sybl T)-- Calculate
eval "(+ 1 2)" --> Ok (Sybl (Num 3))
eval "(+ 1 (* 1 2))" --> Ok (Sybl (Num 3))-- Lambda
eval "((lambda (x) (+ x 1)) 10)" --> Ok (Sybl (Num 11))-- If
eval "((lambda (x) (if (> x 10) x (* x 10))) 3)" --> Ok (Sybl (Num 30))-- Cond
eval """
((lambda (x)
(cond
((eq (mod x 15) 0) "fizzbuzz")
((eq (mod x 3) 0) "fizz")
((eq (mod x 5) 0) "buzz")
(else x)
)
)
15
)
""" --> Ok (Sybl (Str "fizzbuzz"))-- Define function
eval """
(define fact (x)
(if (<= x 1)
x
(* x (fact (- x 1)))
)
)(fact 10)
""" --> Ok (Sybl (Num 3628800))-- comment
eval """
;; this line is comment
(+ 1 2)
"""
```## Modules
### `Ulmus`
Core module
### `Ulmus.AST`
AST module
### `Ulmus.Parser`
Parser module
### `Ulmus.BuildIn`
BuildIn functions