Compare commits

...

5 Commits

Author SHA1 Message Date
92be9e4483 Merge branch 'dev' 2025-07-22 11:49:34 +09:00
ce9e50f2ed Merge branch 'dev' 2025-06-13 18:34:30 +09:00
da617713c3 Fixe documentation 2025-05-10 13:05:02 +09:00
de43cdfefb Renaming libraries 2025-04-15 17:52:32 +09:00
57c2590a84 style(Makefile): whoops 2025-04-15 13:46:39 +09:00
5 changed files with 14 additions and 5 deletions

View File

@ -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"

View File

@ -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 ""))

View File

@ -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"),