Compare commits
No commits in common. "8cf84e63d30856c72bbbcbcb4509ef400b69d1da" and "4d1122fa58c578f3a7819ea892b324efb9a67aa3" have entirely different histories.
8cf84e63d3
...
4d1122fa58
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -33,4 +33,3 @@ target/repl-port
|
||||||
.repl-buffer.janet
|
.repl-buffer.janet
|
||||||
.env
|
.env
|
||||||
src/jpm_tree
|
src/jpm_tree
|
||||||
.zig-cache
|
|
||||||
|
|
14
prelude.ld
14
prelude.ld
|
@ -386,19 +386,6 @@ fn downcase {
|
||||||
(str as :string) -> base :downcase (str)
|
(str as :string) -> base :downcase (str)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn chars {
|
|
||||||
"Takes a string and returns its characters as a list. Works only for strings with only ascii characters. Panics on any non-ascii characters."
|
|
||||||
(str as :string) -> match base :chars (str) {
|
|
||||||
(:ok, chrs) -> chrs
|
|
||||||
(:err, msg) -> panic! msg
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn chars/safe {
|
|
||||||
"Takes a string and returns its characters as a list, wrapped in a result tuple. Works only for strings with only ascii characters. Returns an error tuple on any non-ascii characters."
|
|
||||||
(str as :string) -> base :chars (str)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn ws? {
|
fn ws? {
|
||||||
"Tells if a string is a whitespace character."
|
"Tells if a string is a whitespace character."
|
||||||
(" ") -> true
|
(" ") -> true
|
||||||
|
@ -1399,7 +1386,6 @@ pkg Prelude {
|
||||||
box? & boxes
|
box? & boxes
|
||||||
butlast & lists strings tuples
|
butlast & lists strings tuples
|
||||||
ceil & math
|
ceil & math
|
||||||
chars & strings
|
|
||||||
clear! & turtles
|
clear! & turtles
|
||||||
coll? & dicts lists sets tuples
|
coll? & dicts lists sets tuples
|
||||||
colors & turtles
|
colors & turtles
|
||||||
|
|
|
@ -235,19 +235,6 @@
|
||||||
(defn mod [x y]
|
(defn mod [x y]
|
||||||
(% x y))
|
(% x y))
|
||||||
|
|
||||||
(defn- byte->ascii [c i]
|
|
||||||
(if (< c 128)
|
|
||||||
(string/from-bytes c)
|
|
||||||
(error (string "non-ASCII character at index" i))))
|
|
||||||
|
|
||||||
(defn chars [str]
|
|
||||||
(def out @[])
|
|
||||||
(try
|
|
||||||
(for i 0 (length str)
|
|
||||||
(array/push out (byte->ascii (str i) i)))
|
|
||||||
([e] (break [:err e])))
|
|
||||||
[:ok out])
|
|
||||||
|
|
||||||
(def ctx {
|
(def ctx {
|
||||||
"add" +
|
"add" +
|
||||||
"and" ludus/and
|
"and" ludus/and
|
||||||
|
@ -256,7 +243,6 @@
|
||||||
"atan_2" math/atan2
|
"atan_2" math/atan2
|
||||||
"bool" bool
|
"bool" bool
|
||||||
"ceil" math/ceil
|
"ceil" math/ceil
|
||||||
"chars" chars
|
|
||||||
"concat" concat
|
"concat" concat
|
||||||
"conj!" conj!
|
"conj!" conj!
|
||||||
"conj" conj
|
"conj" conj
|
||||||
|
@ -312,9 +298,10 @@
|
||||||
"upcase" string/ascii-upper
|
"upcase" string/ascii-upper
|
||||||
})
|
})
|
||||||
|
|
||||||
(def base (let [b @{:^type :dict}]
|
(def base (let [b @{}]
|
||||||
(each [k v] (pairs ctx)
|
(each [k v] (pairs ctx)
|
||||||
(set (b (keyword k)) v))
|
(set (b (keyword k)) v))
|
||||||
b))
|
b))
|
||||||
|
|
||||||
|
(set (base :^type) :dict)
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
"lists" ["any?" "append" "at" "butlast" "coll?" "concat" "count" "each!" "empty?" "filter" "first" "fold" "join" "keep" "last" "list" "list?" "map" "ordered?" "random" "range" "rest" "second" "sentence" "slice"]
|
"lists" ["any?" "append" "at" "butlast" "coll?" "concat" "count" "each!" "empty?" "filter" "first" "fold" "join" "keep" "last" "list" "list?" "map" "ordered?" "random" "range" "rest" "second" "sentence" "slice"]
|
||||||
"sets" ["any?" "append" "coll?" "concat" "contains?" "count" "empty?" "omit" "random" "set" "set?"]
|
"sets" ["any?" "append" "coll?" "concat" "contains?" "count" "empty?" "omit" "random" "set" "set?"]
|
||||||
"tuples" ["any?" "at" "coll?" "count" "empty?" "first" "last" "ordered?" "rest" "second" "tuple?"]
|
"tuples" ["any?" "at" "coll?" "count" "empty?" "first" "last" "ordered?" "rest" "second" "tuple?"]
|
||||||
"strings" ["any?" "chars" "chars/safe" "concat" "count" "downcase" "empty?" "join" "sentence" "show" "slice" "split" "string" "string?" "strip" "trim" "upcase" "words"]
|
"strings" ["any?" "concat" "count" "downcase" "empty?" "join" "sentence" "show" "slice" "split" "string" "string?" "strip" "trim" "upcase" "words"]
|
||||||
"types and values" ["assoc?" "bool?" "box?" "coll?" "dict?" "eq?" "fn?" "keyword?" "list?" "neq?" "nil?" "number?" "ordered?" "set?" "show" "some" "some?" "string?" "tuple?" "type"]
|
"types and values" ["assoc?" "bool?" "box?" "coll?" "dict?" "eq?" "fn?" "keyword?" "list?" "neq?" "nil?" "number?" "ordered?" "set?" "show" "some" "some?" "string?" "tuple?" "type"]
|
||||||
"boxes and state" ["box?" "unbox" "store!" "update!"]
|
"boxes and state" ["box?" "unbox" "store!" "update!"]
|
||||||
"results" ["err" "err?" "ok" "ok?" "unwrap!" "unwrap_or"]
|
"results" ["err" "err?" "ok" "ok?" "unwrap!" "unwrap_or"]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user