1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-11 13:55:55 +03:00

add core keyword, symbol and type predicates

This commit is contained in:
Fabian 2021-04-05 19:48:41 +02:00 committed by Joel Martin
parent a8d4e41be6
commit f2a37a3ae4

View File

@ -121,7 +121,23 @@ val coreCmp = [
SYMBOL "symbol?",
FN (fn [SYMBOL _] => BOOL true | [_] => BOOL false
| _ => raise NotApplicable "symbol? requires one argument")
| _ => raise NotApplicable "symbol? requires one argument"),
SYMBOL "keyword?",
FN (fn [KEYWORD _] => BOOL true | [_] => BOOL false
| _ => raise NotApplicable "keyword? requires one argument"),
SYMBOL "vector?",
FN (fn [VECTOR _] => BOOL true | [_] => BOOL false
| _ => raise NotApplicable "vector? requires one argument"),
SYMBOL "sequential?",
FN (fn [LIST _] => BOOL true | [VECTOR _] => BOOL true | [_] => BOOL false
| _ => raise NotApplicable "sequential? requires one argument"),
SYMBOL "map?",
FN (fn [MAP _] => BOOL true | [_] => BOOL false
| _ => raise NotApplicable "map? requires one argument")
]
val coreMath = [
@ -144,7 +160,15 @@ val coreString = [
FN (fn args => args |> List.map prReadableStr |> String.concatWith " " |> STRING),
SYMBOL "str",
FN (fn args => args |> List.map prStr |> String.concatWith "" |> STRING)
FN (fn args => args |> List.map prStr |> String.concatWith "" |> STRING),
SYMBOL "symbol",
FN (fn [STRING s] => SYMBOL s
| _ => raise NotApplicable "symbol requires a string"),
SYMBOL "keyword",
FN (fn [STRING s] => KEYWORD s
| _ => raise NotApplicable "keyword requires a string")
]
val coreAtom = [