mirror of
https://github.com/janet-lang/janet
synced 2025-03-02 06:30:03 +00:00
Fix some indentation problems.
This commit is contained in:
parent
2a5234b390
commit
31e2415bbb
@ -232,8 +232,8 @@
|
|||||||
(while (> i 0)
|
(while (> i 0)
|
||||||
(-- i)
|
(-- i)
|
||||||
(set ret (if (= ret true)
|
(set ret (if (= ret true)
|
||||||
(get forms i)
|
(get forms i)
|
||||||
(tuple 'if (get forms i) ret))))
|
(tuple 'if (get forms i) ret))))
|
||||||
ret)
|
ret)
|
||||||
|
|
||||||
(defmacro or
|
(defmacro or
|
||||||
@ -247,11 +247,11 @@
|
|||||||
(-- i)
|
(-- i)
|
||||||
(def fi (get forms i))
|
(def fi (get forms i))
|
||||||
(set ret (if (idempotent? fi)
|
(set ret (if (idempotent? fi)
|
||||||
(tuple 'if fi fi ret)
|
(tuple 'if fi fi ret)
|
||||||
(do
|
(do
|
||||||
(def $fi (gensym))
|
(def $fi (gensym))
|
||||||
(tuple 'do (tuple 'def $fi fi)
|
(tuple 'do (tuple 'def $fi fi)
|
||||||
(tuple 'if $fi $fi ret))))))
|
(tuple 'if $fi $fi ret))))))
|
||||||
ret)
|
ret)
|
||||||
|
|
||||||
(defmacro with-syms
|
(defmacro with-syms
|
||||||
@ -483,7 +483,7 @@
|
|||||||
4 (let [[f g h i] functions] (fn [x] (f (g (h (i x))))))
|
4 (let [[f g h i] functions] (fn [x] (f (g (h (i x))))))
|
||||||
(let [[f g h i j] functions]
|
(let [[f g h i j] functions]
|
||||||
(comp (fn [x] (f (g (h (i (j x))))))
|
(comp (fn [x] (f (g (h (i (j x))))))
|
||||||
;(tuple/slice functions 5 -1)))))
|
;(tuple/slice functions 5 -1)))))
|
||||||
|
|
||||||
(defn identity
|
(defn identity
|
||||||
"A function that returns its first argument."
|
"A function that returns its first argument."
|
||||||
@ -882,8 +882,8 @@
|
|||||||
|
|
||||||
(defn invert
|
(defn invert
|
||||||
"Returns a table of where the keys of an associative data structure
|
"Returns a table of where the keys of an associative data structure
|
||||||
are the values, and the values of the keys. If multiple keys have the same
|
are the values, and the values of the keys. If multiple keys have the same
|
||||||
value, one key will be ignored."
|
value, one key will be ignored."
|
||||||
[ds]
|
[ds]
|
||||||
(def ret @{})
|
(def ret @{})
|
||||||
(loop [k :keys ds]
|
(loop [k :keys ds]
|
||||||
@ -979,7 +979,7 @@ value, one key will be ignored."
|
|||||||
(def len (min ;(map length cols)))
|
(def len (min ;(map length cols)))
|
||||||
(loop [i :range [0 len]
|
(loop [i :range [0 len]
|
||||||
ci :range [0 ncol]]
|
ci :range [0 ncol]]
|
||||||
(array/push res (get (get cols ci) i))))
|
(array/push res (get (get cols ci) i))))
|
||||||
res)
|
res)
|
||||||
|
|
||||||
(defn distinct
|
(defn distinct
|
||||||
@ -1153,15 +1153,15 @@ value, one key will be ignored."
|
|||||||
match if it is equal to x."
|
match if it is equal to x."
|
||||||
[x & cases]
|
[x & cases]
|
||||||
(with-idemp $x x
|
(with-idemp $x x
|
||||||
(def len (length cases))
|
(def len (length cases))
|
||||||
(def len-1 (dec len))
|
(def len-1 (dec len))
|
||||||
((fn aux [i]
|
((fn aux [i]
|
||||||
(cond
|
(cond
|
||||||
(= i len-1) (get cases i)
|
(= i len-1) (get cases i)
|
||||||
(< i len-1) (with-syms [$res]
|
(< i len-1) (with-syms [$res]
|
||||||
~(if (= ,sentinel (def ,$res ,(match-1 (get cases i) $x (fn [] (get cases (inc i))) @{})))
|
~(if (= ,sentinel (def ,$res ,(match-1 (get cases i) $x (fn [] (get cases (inc i))) @{})))
|
||||||
,(aux (+ 2 i))
|
,(aux (+ 2 i))
|
||||||
,$res)))) 0)))
|
,$res)))) 0)))
|
||||||
|
|
||||||
(put _env 'sentinel nil)
|
(put _env 'sentinel nil)
|
||||||
(put _env 'match-1 nil)
|
(put _env 'match-1 nil)
|
||||||
@ -1201,14 +1201,14 @@ value, one key will be ignored."
|
|||||||
|
|
||||||
(each b text
|
(each b text
|
||||||
(if (and (not= b 10) (not= b 32))
|
(if (and (not= b 10) (not= b 32))
|
||||||
(if (= b 9)
|
(if (= b 9)
|
||||||
(buffer/push-string word " ")
|
(buffer/push-string word " ")
|
||||||
(buffer/push-byte word b))
|
(buffer/push-byte word b))
|
||||||
(do
|
(do
|
||||||
(if (> (length word) 0) (pushword))
|
(if (> (length word) 0) (pushword))
|
||||||
(when (= b 10)
|
(when (= b 10)
|
||||||
(buffer/push-string buf "\n ")
|
(buffer/push-string buf "\n ")
|
||||||
(set current 0)))))
|
(set current 0)))))
|
||||||
|
|
||||||
# Last word
|
# Last word
|
||||||
(pushword)
|
(pushword)
|
||||||
@ -1611,9 +1611,9 @@ value, one key will be ignored."
|
|||||||
(def paths (map make-full module/paths))
|
(def paths (map make-full module/paths))
|
||||||
(def res (find check-path paths))
|
(def res (find check-path paths))
|
||||||
(if res res [nil (string "could not find module "
|
(if res res [nil (string "could not find module "
|
||||||
path
|
path
|
||||||
":\n "
|
":\n "
|
||||||
;(interpose "\n " (map 0 paths)))]))
|
;(interpose "\n " (map 0 paths)))]))
|
||||||
|
|
||||||
(put _env 'fexists nil)
|
(put _env 'fexists nil)
|
||||||
|
|
||||||
@ -1637,35 +1637,36 @@ value, one key will be ignored."
|
|||||||
(do
|
(do
|
||||||
(def [fullpath mod-kind] (module/find path))
|
(def [fullpath mod-kind] (module/find path))
|
||||||
(unless fullpath (error mod-kind))
|
(unless fullpath (error mod-kind))
|
||||||
(def env (case mod-kind
|
(def env
|
||||||
:source (do
|
(case mod-kind
|
||||||
# Normal janet module
|
:source (do
|
||||||
(def f (file/open fullpath))
|
# Normal janet module
|
||||||
(def newenv (make-env))
|
(def f (file/open fullpath))
|
||||||
(put module/loading fullpath true)
|
(def newenv (make-env))
|
||||||
(defn chunks [buf _] (file/read f 2048 buf))
|
(put module/loading fullpath true)
|
||||||
(defn bp [&opt x y]
|
(defn chunks [buf _] (file/read f 2048 buf))
|
||||||
(def ret (bad-parse x y))
|
(defn bp [&opt x y]
|
||||||
(if exit-on-error (os/exit))
|
(def ret (bad-parse x y))
|
||||||
ret)
|
(if exit-on-error (os/exit 1))
|
||||||
(defn bc [&opt x y z]
|
ret)
|
||||||
(def ret (bad-compile x y z))
|
(defn bc [&opt x y z]
|
||||||
(if exit-on-error (os/exit))
|
(def ret (bad-compile x y z))
|
||||||
ret)
|
(if exit-on-error (os/exit 1))
|
||||||
(run-context {:env newenv
|
ret)
|
||||||
:chunks chunks
|
(run-context {:env newenv
|
||||||
:on-parse-error bp
|
:chunks chunks
|
||||||
:on-compile-error bc
|
:on-parse-error bp
|
||||||
:on-status (fn [f x]
|
:on-compile-error bc
|
||||||
(when (not= (fiber/status f) :dead)
|
:on-status (fn [f x]
|
||||||
(debug/stacktrace f x)
|
(when (not= (fiber/status f) :dead)
|
||||||
(if exit-on-error (os/exit 1))))
|
(debug/stacktrace f x)
|
||||||
:source fullpath})
|
(if exit-on-error (os/exit 1))))
|
||||||
(file/close f)
|
:source fullpath})
|
||||||
(put module/loading fullpath nil)
|
(file/close f)
|
||||||
(table/setproto newenv nil))
|
(put module/loading fullpath nil)
|
||||||
:native (native fullpath (make-env))
|
(table/setproto newenv nil))
|
||||||
:image (load-image (slurp fullpath))))
|
:native (native fullpath (make-env))
|
||||||
|
:image (load-image (slurp fullpath))))
|
||||||
(put module/cache fullpath env)
|
(put module/cache fullpath env)
|
||||||
(put module/cache path env)
|
(put module/cache path env)
|
||||||
env)))
|
env)))
|
||||||
|
@ -419,8 +419,8 @@ static const JanetReg corelib_cfuns[] = {
|
|||||||
{
|
{
|
||||||
"getline", janet_core_getline,
|
"getline", janet_core_getline,
|
||||||
JDOC("(getline [, prompt=\"\" [, buffer=@\"\"]])\n\n"
|
JDOC("(getline [, prompt=\"\" [, buffer=@\"\"]])\n\n"
|
||||||
"Reads a line of input into a buffer, including the newline character, using a prompt. Returns the modified buffer. "
|
"Reads a line of input into a buffer, including the newline character, using a prompt. Returns the modified buffer. "
|
||||||
"Use this function to implement a simple interface for a terminal program.")
|
"Use this function to implement a simple interface for a terminal program.")
|
||||||
},
|
},
|
||||||
{NULL, NULL, NULL}
|
{NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user