mirror of
https://github.com/teo3300/rust-mal.git
synced 2026-01-12 09:15:32 +01:00
Compare commits
5 Commits
dev
...
92be9e4483
| Author | SHA1 | Date | |
|---|---|---|---|
| 92be9e4483 | |||
| ce9e50f2ed | |||
| da617713c3 | |||
| de43cdfefb | |||
| 57c2590a84 |
6
Makefile
6
Makefile
@ -23,6 +23,10 @@ conf: test
|
||||
@test -s ${CONFIG_FILE} || (\
|
||||
echo ";; Write here your mal config" >> ${MAL_HOME}/config.mal\
|
||||
&& echo "; (def! BANNER \"\") ; Hide banner at startup" >> ${MAL_HOME}/config.mal\
|
||||
&& echo '' >> ${MAL_HOME}/config.mal\
|
||||
&& echo '(def! BANNER (str BANNER' >> ${MAL_HOME}/config.mal\
|
||||
&& echo '";\n; **** To remove this banner and config mal, edit: ****\n"' >> ${MAL_HOME}/config.mal\
|
||||
&& echo '"; /Users/rogora/.config/mal/config.mal\n"))' >> ${MAL_HOME}/config.mal\
|
||||
)
|
||||
|
||||
install: build-release test conf
|
||||
@ -41,4 +45,4 @@ install: build-release test conf
|
||||
@echo "To start mal run:"
|
||||
@printf "\tmal [path/to/script [args ...]]\n\n"
|
||||
@echo "To config mal edit:"
|
||||
@printf "\t${MAL_HOME}/config.mal"
|
||||
@printf "\t${MAL_HOME}/config.mal\n"
|
||||
|
||||
@ -32,9 +32,7 @@
|
||||
(split-r (cdr l) (str t cc) r))))))
|
||||
(reverse (split-r s "" '()))))
|
||||
|
||||
(def! split (fn* [string delimiter]
|
||||
"Split the string at every occurrence of substring delimiter"
|
||||
"An empty delimiter is splitting every character"
|
||||
(def! split-h (fn* [string delimiter]
|
||||
(if (= (strlen delimiter) 1)
|
||||
(_split-ch string (char delimiter))
|
||||
(do (def! delimiter (boom delimiter))
|
||||
@ -50,6 +48,13 @@
|
||||
(split-r string delimiter "" (str chunk matches curr) chunks)))))))
|
||||
(reverse (split-r (boom string) delimiter "" "" '()))))))
|
||||
|
||||
(def! split (fn* [string delimiter]
|
||||
"Split the string at every occurrence of substring delimiter"
|
||||
"An empty delimiter is splitting every character"
|
||||
(if (= (strlen delimiter) 0)
|
||||
(cdr (split-h string delimiter))
|
||||
(split-h string delimiter))))
|
||||
|
||||
(def! join (fn* [l s]
|
||||
"Join element of list l to a stiring, using s as separator"
|
||||
(def! s (or s ""))
|
||||
|
||||
@ -70,7 +70,7 @@ pub fn ns_init() -> Env {
|
||||
"<=" => Fun(|a| comparison_op( |a, b| a <= b, a), "Returns true if the first argument is smaller than or equal to the second one, nil otherwise"),
|
||||
">=" => Fun(|a| comparison_op( |a, b| a >= b, a), "Returns true if the first argument is greater than or equal to the second one, nil otherwise"),
|
||||
"pr-str" => Fun(|a| Ok(Str(a.iter().map(|i| pr_str(i, true)).collect::<Vec<String>>().join("").into())), "Print readably all arguments"),
|
||||
"str" => Fun(|a| Ok(Str(a.iter().map(|i| pr_str(i, false)).collect::<Vec<String>>().join("").into())), "Print non readably all arguments"),
|
||||
"str" => Fun(|a| Ok(Str(a.iter().map(|i| pr_str(i, false)).collect::<Vec<String>>().join("").into())), "Concatenate all arguments as a string"),
|
||||
"prn" => Fun(|a| {a.iter().for_each(|a| print!("{}", pr_str(a, false))); let _ = io::stdout().flush(); Ok(Nil) }, "Print readably all the arguments"),
|
||||
"println" => Fun(|a| {a.iter().for_each(|a| print!("{}", pr_str(a, false))); println!(); Ok(Nil) }, "Print readably all the arguments"),
|
||||
"list" => Fun(|a| Ok(List(a.into())), "Return the arguments as a list"),
|
||||
|
||||
Reference in New Issue
Block a user