From 2f213e859ecfdc293a111ec5cef311dca82cecd0 Mon Sep 17 00:00:00 2001 From: Alexandre Plateau Date: Tue, 3 Aug 2021 17:13:33 +0200 Subject: [PATCH] Updating the documentation snippets used --- Events.ark | 26 ++++------------ Exceptions.ark | 15 ++------- Functional.ark | 18 ++--------- List.ark | 84 +++++++++++++++----------------------------------- Math.ark | 44 ++++++-------------------- README.md | 16 +++++----- Range.ark | 13 +------- String.ark | 17 +--------- Switch.ark | 5 +-- os.ark | 22 ++++++------- 10 files changed, 67 insertions(+), 193 deletions(-) diff --git a/Events.ark b/Events.ark index 6e211a3..0536fab 100644 --- a/Events.ark +++ b/Events.ark @@ -1,7 +1,5 @@ (import "List.ark") -### -# @meta Events # @brief Allows to register events listeners and emit events # =begin # (let em (events:manager:make)) @@ -9,12 +7,10 @@ # (em.emit "myType") # => prints "This is a callback" thanks to the registered listener # =end # @author https://github.com/fabien-zoccola -## (let events:manager:make (fun () { # listeners list (mut _listeners []) - ### # @brief Checks if a given callback is valid (is a function or a closure) # @param callback the callback to check # @details Returns true if the callback is a function/closure, false otherwise @@ -24,11 +20,9 @@ # (closure._check_valid 5) # => false # =end # @author https://github.com/fabien-zoccola - ## (let _check_valid (fun (callback) - (or (= "Function" (type callback)) (= "Closure" (type callback)) ))) + (or (= "Function" (type callback)) (= "Closure" (type callback))))) - ### # @brief Registers an event listener # @param typ the type of the event to listen for # @param callback the function/closure that will be called when an event is emitted @@ -37,12 +31,10 @@ # (closure.on "myType" (fun (param) ()) # =end # @author https://github.com/fabien-zoccola - ## (let on (fun (typ callback) (if (_check_valid callback) (set _listeners (append _listeners [typ callback]))))) - ### # @brief Emits an event with a value # @param val the emitted value # @param typ the type of the emitted event @@ -51,7 +43,6 @@ # (closure.emitWith 5 "myType") # =end # @author https://github.com/fabien-zoccola - ## (let emitWith (fun (val typ) { (mut found false) (list:forEach _listeners (fun (element) @@ -61,9 +52,7 @@ }))) found })) - - ### # @brief Emits an event with no value # @param typ the type of the emitted event # @details Calls emitWith nil @@ -71,11 +60,9 @@ # (closure.emit "myType") # =end # @author https://github.com/fabien-zoccola - ## (let emit (fun (typ) - (emitWith nil typ) )) + (emitWith nil typ))) - ### # @brief Removes all listeners of a given type # @param typ the type of event to remove from the list # @details Returns if at least one listener has been removed @@ -83,10 +70,9 @@ # (closure.remove_listeners_of_type "myType") # =end # @author https://github.com/fabien-zoccola - ## (let removeListenersOfType (fun (typ) { - (let newlist (list:filter _listeners (fun (element) - (!= typ (@ element 0)) ))) + (let newlist + (list:filter _listeners (fun (element) (!= typ (@ element 0))))) (let deleted (!= newlist _listeners)) (set _listeners newlist) deleted @@ -98,11 +84,11 @@ # hidden methods &_check_valid - + # methods &on &emit &emitWith &removeListenersOfType ) ()) -})) \ No newline at end of file +})) diff --git a/Exceptions.ark b/Exceptions.ark index 3b14a88..599ca6a 100644 --- a/Exceptions.ark +++ b/Exceptions.ark @@ -1,29 +1,21 @@ -### -# @meta Exceptions # @brief throw takes a value as its argument and return it to be used by try # @param _x the value to return # =begin # (let error (throw "cannot divide by zero")) # =end # @author https://github.com/SuperFola -## (let throw (fun (_x) - (fun (_injl _injr &_x) (_injl _x)) -)) + (fun (_injl _injr &_x) (_injl _x)))) -### # @brief return takes a value as its argument and return it to be used by try # @param _x the value to return # =begin # (let value (return (/ 1 x))) # =end # @author https://github.com/SuperFola -## (let return (fun (_y) - (fun (_injl _injr &_y) (_injr _y)) -)) + (fun (_injl _injr &_y) (_injr _y)))) -### # @brief Takes a value either returned by throw or return and apply a given on it if it's an error or not # @param _either the value to test # @param _continue the success handler @@ -38,6 +30,5 @@ # (fun (err) (print err))) # =end # @author https://github.com/SuperFola -## (let try (fun (_either _continue _handle) - (_either _handle _continue))) \ No newline at end of file + (_either _handle _continue))) diff --git a/Functional.ark b/Functional.ark index 67a42be..b0fccfb 100644 --- a/Functional.ark +++ b/Functional.ark @@ -1,5 +1,3 @@ -### -# @meta Functional # @brief Compose function calls # @param _f the first function # @param _g the second function @@ -10,11 +8,9 @@ # (print (composed 12)) # return value is (12 + 12) * (12 + 12) # =end # @author https://github.com/rstefanic -## (let compose (fun (_f _g) (fun (_y &_f &_g) (_f (_g _y))))) -### # @brief Take a value as its argument and return a function taking 2 arguments which will call the first function on the value # @param _x the value # =begin @@ -22,12 +18,9 @@ # (val (fun (x) (print x " i am called")) (fun (x) (print x " i am NOT called"))) # =end # @author https://github.com/SuperFola -## (let left (fun (_x) - (fun (_injl _injr &_x) (_injl _x)) -)) + (fun (_injl _injr &_x) (_injl _x)))) -### # @brief Take a value as its argument and return a function taking 2 arguments which will call the second function on the value # @param _y the value # =begin @@ -35,12 +28,9 @@ # (val (fun (x) (print x " i am NOT called")) (fun (x) (print x " i am called"))) # =end # @author https://github.com/SuperFola -## (let right (fun (_y) - (fun (_injl _injr &_y) (_injr _y)) -)) + (fun (_injl _injr &_y) (_injr _y)))) -### # @brief Flip the arguments of a function # @param _f the function # @param _a the first argument @@ -49,8 +39,6 @@ # (let foo (fun (a b) (- a b))) # ((flip foo 14) 12) # will call (foo 12 14) instead of (foo 14 12) # =end - # @author https://github.com/rstefanic -## (let flip (fun (_f _a) - (fun (_b &_f &_a) (_f _b _a)))) \ No newline at end of file + (fun (_b &_f &_a) (_f _b _a)))) diff --git a/List.ark b/List.ark index 47204be..f26c60f 100644 --- a/List.ark +++ b/List.ark @@ -1,5 +1,3 @@ -### -# @meta List # @brief Iterate over a given list and run a given function on every element. # @param _L the list to iterate over # @param _func the function to call on each element @@ -12,7 +10,6 @@ # })) # =end # @author https://github.com/SuperFola -## (let list:forEach (fun (_L _func) { (mut _index 0) (while (< _index (len _L)) { @@ -22,7 +19,6 @@ }) })) -### # @brief Iterate over a given list and multiply all the elements with the others. # @param _L the list to iterate over # @details The original list is left unmodified. @@ -32,7 +28,6 @@ # (let p (list:product collection)) # => 120 # =end # @author https://github.com/FrenchMasterSword -## (let list:product (fun (_L) { (mut _index 0) (mut _output 1) @@ -43,7 +38,6 @@ _output })) -### # @brief Iterate over a given list and sum all the elements. # @param _L the list to iterate over # @details The original list is left unmodified. @@ -51,9 +45,8 @@ # (import "List.ark") # (let collection [1 2 5 12]) # (let p (list:sum collection)) # => 20 -# =begin +# =end # @author https://github.com/FrenchMasterSword -## (let list:sum (fun (_L) { (mut _index 0) (mut _output 0) @@ -66,7 +59,6 @@ (import "Math.ark") # needed for math:min, math:max -### # @brief Drop the first n elements of a list # @param _L the list to work on # @param _n the number of elements to drop @@ -76,7 +68,6 @@ # (print (list:drop cool-stuff 4)) # [5 6 7 8 9] # =end # @author https://github.com/rstefanic -## (let list:drop (fun (_L _n) { (mut _index (math:max 0 _n)) (mut _output []) @@ -87,7 +78,6 @@ _output })) -### # @brief Drop the first elements of a list, while they match a given predicate # @param _L the list to work on # @param _f the predicate @@ -97,7 +87,6 @@ # (print (list:dropWhile cool-stuff (fun (a) (< a 4)))) # [4 5 6 7 8 9] # =end # @author https://github.com/SuperFola -## (let list:dropWhile (fun (_L _f) { (mut _index 0) (mut _output []) @@ -112,7 +101,6 @@ _output })) -### # @brief Keep elements in a given list if they follow a predicate # @param _L the list to work on # @param _f the predicate @@ -122,7 +110,6 @@ # (print (list:filter [1 2 3 4 5 6 7 8 9] math:even)) # [2 4 6 8] # =end # @author https://github.com/rstefanic -## (let list:filter (fun (_L _f) { (mut _index 0) (mut _output []) @@ -134,7 +121,6 @@ _output })) -### # @brief Apply a given function to each element of a list # @param _L the list to work on # @param _f the function to apply to each element @@ -143,7 +129,6 @@ # (print (list:map [1 2 3 4 5 6 7 8 9] (fun (e) (* e e)))) # [1 4 9 25 36 49 64 81] # =end # @author https://github.com/rstefanic -## (let list:map (fun (_L _f) { (mut _index 0) (mut _output []) @@ -154,7 +139,6 @@ _output })) -### # @brief Apply a function to the elements of a list to reduce it # @param _L the list to work on # @param _f the function to apply @@ -164,7 +148,6 @@ # (print (list:reduce cool (fun (a b) (+ a b)))) # 45 # =end # @author https://github.com/FrenchMasterSword -## (let list:reduce (fun (_L _f) { (mut _index 1) (mut _output (@ _L 0)) @@ -175,7 +158,6 @@ _output })) -### # @brief Flatten a list # @param _L the list to work on # @details The original list is left unmodified. @@ -184,7 +166,6 @@ # (print (list:flatten cool)) # [1 2 3 4 5 6 7 8 9] # =end # @author https://github.com/SuperFola -## (let list:flatten (fun (_L) { (mut _index 0) (mut _output []) @@ -198,7 +179,6 @@ _output })) -### # @brief Apply a given function to each element of a list and then flatten it # @param _L the list to work on # @param _f the function to apply to each element @@ -208,7 +188,6 @@ # (print (list:flatMap cool (fun (a) [a a]))) # [1 1 2 2 3 3 4 4] # =end # @author https://github.com/SuperFola -## (let list:flatMap (fun (_L _f) { (mut _index 0) (mut _output []) @@ -222,8 +201,6 @@ _output })) -### -# @meta List # @brief Take the first n elements of # @param _L the list to work on # @param _n the number of elements to take @@ -232,7 +209,6 @@ # (print (list:take [1 2 3 4 5 6 7 8 9] 4)) # [1 2 3 4] # =end # @author https://github.com/rstefanic -## (let list:take (fun (_L _n) { (mut _index 0) (mut _output []) @@ -245,7 +221,6 @@ _output })) -### # @brief Unzip a list of [[a b] [c d]...] into [[a c ...] [b d ...]] # @param _L the list to work on # @details The original list is left unmodified. @@ -254,7 +229,6 @@ # (print (list:unzip zipped)) # [[1 2 3 4] [5 6 7 8]] # =end # @author https://github.com/FrenchMasterSword -## (let list:unzip (fun (_L) { (let _m (len _L)) (mut _list1 []) @@ -269,7 +243,6 @@ [_list1 _list2] })) -### # @brief Zip two lists into one: [1 2 3 4] and [5 6 7 8] will give [[1 5] [2 6] [3 7] [4 8]] # @param _a the first list to work on # @param _b the second list to work on @@ -280,7 +253,6 @@ # (print (list:zip a b)) # [[1 5] [2 6] [3 7] [4 8]] # =end # @author https://github.com/FrenchMasterSword -## (let list:zip (fun (_a _b) { (let _m (math:min (len _a) (len _b))) (mut _c []) @@ -292,7 +264,6 @@ _c })) -### # @brief Fold a given list, starting from the left side # @param _L the list to work on # @param _init an init value @@ -303,7 +274,6 @@ # (print (list:foldLeft a 0 (fun (a b) (+ a b)))) # 10 # =end # @author https://github.com/SuperFola -## (let list:foldLeft (fun (_L _init _f) { (mut _index 0) (mut _val _init) @@ -314,48 +284,42 @@ _val })) -### # @brief Check if a condition is verified for all elements of a list -# @param a the list to work on -# @param f the conditon +# @param _L the list to work on +# @param _f the conditon # =begin # (let a [1 2 3 4]) -# (let f (fun(e)(< e 5))) +# (let f (fun (e) (< e 5))) # (print (list:forAll a f)) # true # =end # @author https://github.com/Gryfenfer97 -## -(let list:forAll (fun (a f) { - (mut verified true) - (mut index 0) - (while (and verified (< index (len a))) { - (if (not (f (@ a index))) - (set verified false) - ) - (set index (+ 1 index)) +(let list:forAll (fun (_L _f) { + (mut _verified true) + (mut _index 0) + (while (and _verified (< _index (len _L))) { + (if (not (_f (@ _L _index))) + (set _verified false)) + (set _index (+ 1 _index)) }) - verified + _verified })) -### # @brief Check if a condition if verified for one or more elements of a list -# @param a the list to work on -# @param f the conditon +# @param _L the list to work on +# @param _f the conditon # =begin # (let a [1 2 3 4]) -# (let f (fun(e)(< e 3))) +# (let f (fun (e) (< e 3))) # (print (list:any a f)) # true # =end # @author https://github.com/Gryfenfer97 -## -(let list:any (fun (a f) { - (mut verified false) - (mut index 0) - (while (and (not verified) (< index (len a))) { - (if (f (@ a index)) - (set verified true) - ) - (set index (+ 1 index)) +(let list:any (fun (_L _f) { + (mut _verified false) + (mut _index 0) + (while (and (not _verified) (< _index (len _L))) { + (if (_f (@ _L _index)) + (set _verified true)) + (set _index (+ 1 _index)) }) - verified -})) \ No newline at end of file + _verified +})) diff --git a/Math.ark b/Math.ark index e799638..352412b 100644 --- a/Math.ark +++ b/Math.ark @@ -1,64 +1,50 @@ -### -# @meta Mathematics # @brief Return the absolute value of a number # @param _x the number to get the absolute value of # @author https://github.com/rstefanic -## (let math:abs (fun (_x) (if (< _x 0) (* -1 _x) _x))) -### # @brief Return true if the number is even, false otherwise # @param _n the number # @author https://github.com/rstefanic -## (let math:even (fun (_n) (= 0 (mod _n 2)))) -### # @brief Return true if the number is odd, false otherwise # @param _n the number # @author https://github.com/rstefanic -## (let math:odd (fun (_n) (= 1 (math:abs (mod _n 2))))) -### # @brief Get the minimum between two numbers # @param _a the first number # @param _b the second number # @author https://github.com/rstefanic -## (let math:min (fun (_a _b) (if (< _a _b) _a _b))) -### # @brief Get the maximum between two numbers # @param _a the first number # @param _b the second number # @author https://github.com/rstefanic -## (let math:max (fun (_a _b) (if (> _a _b) _a _b))) -### # @brief Get a number to a given power # @details Note that it's defined as exp(a * ln(x)), thus won't work for negative numbers # @param _x the number to pow # @param _a the exponent # @author https://github.com/SuperFola -## -(let math:pow (fun (_x _a) (math:exp (* _a (math:ln _x))))) +(let math:pow (fun (_x _a) + (math:exp (* _a (math:ln _x))))) -### # @brief Get the square root of a number # @details Square roots can't be taken for negative numbers for obvious reasons. # @param _x the number # @author https://github.com/SuperFola -## -(let math:sqrt (fun (_x) (math:exp (* 0.5 (math:ln _x))))) +(let math:sqrt (fun (_x) + (math:exp (* 0.5 (math:ln _x))))) -### # @brief Run the fibonacci function on a number # @param n the number # @param p an accumulator @@ -67,7 +53,6 @@ # =begin # (math:fibo 45 0 1) # =end -## (let math:fibo (fun (n p c) { (if (<= n 0) 0 @@ -75,14 +60,12 @@ c (math:fibo (- n 1) c (+ p c))))})) -### # @brief Returns the list of a number's divisors # @param n the number # @author https://github.com/Wafelack # =begin # (math:divs 6) # Returns [1 2 3 6] # =end -## (let math:divs (fun (n) { (assert (>= n 2) "math:divs: n must be greater or equal to 2") (mut i 2) @@ -95,7 +78,6 @@ }) (append divisors n)})) -### # @brief Returns the logarithm base n of a number # @param x the number # @param n the base @@ -103,35 +85,29 @@ # =begin # (math:log 81 3) # Returns 4 # =end -## (let math:log (fun (x n) { (assert (> x 0) "math:log: x must be greater than 0") (assert (>= n 1) "math:log: n must be greater or equal to 1") (math:round (/ (math:ln x) (math:ln n)))})) -### # @brief Returns the logarithm base 2 of a number # @param x the number # @author https://github.com/Gryfenfer97 # =begin # (math:log2 128) # Returns 7 # =end -## -(let math:log2 (fun (x) { - (math:log x 2)})) +(let math:log2 (fun (x) + (math:log x 2))) -### # @brief Returns the logarithm base 10 of a number # @param x the number # @author https://github.com/Gryfenfer97 # =begin # (math:log10 1000) # Returns 3 # =end -## -(let math:log10 (fun (x) { - (math:log x 10)})) +(let math:log10 (fun (x) + (math:log x 10))) -### # @brief Returns the quotient of the euclidian division of a and b # @param a the dividend # @param b the divisor @@ -139,5 +115,5 @@ # =begin # (math:floordiv 14 6) # Returns 2 # =end -## -(let math:floordiv (fun (a b) (math:floor (/ a b)))) \ No newline at end of file +(let math:floordiv (fun (a b) + (math:floor (/ a b)))) diff --git a/README.md b/README.md index b2e0fe7..60f7fe9 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ Complete documentation is available online at [arkscript-lang/std](https://arksc You can also generate yourself by using our documentation generator, [ArkDoc](https://github.com/ArkScript-lang/ArkDoc): ```shell -$ pip install mkdocs -# default folder for ArkDoc (to search code in) is "./source/" -$ mkdir source -$ cp ../std/*.ark source/ -$ ruby ArkDoc.rb -g "ArkScript" -# open your browser to read the generate doc -$ sensible-browser docs/site/ArkScript/ -``` \ No newline at end of file +python3 -m venv venv +source ./venv/bin/activate +pip install -r requirements.txt +python -m arkdoc . --html out +cd out && python -m http.server +``` + +Then, open your webbrowser to go to `http://localhost:8000/`. diff --git a/Range.ark b/Range.ark index bcd7ba0..a3b1921 100644 --- a/Range.ark +++ b/Range.ark @@ -1,5 +1,3 @@ -### -# @meta Range # @brief Create a ranged closure in interval [a, b[ # @param i the beginning of the range # @param _b the end of the range @@ -14,7 +12,6 @@ # (print (obj.asList)) # [1 2 3 4 5 6 7 8 9] # =end # @author https://github.com/SuperFola -## (let range (fun (i _b) { (let asList (fun () { # i and _b are going to be captured by the caller @@ -39,7 +36,6 @@ }) })) -### # @brief Run a function on each element of the range # @param _r the range object # @param _f the function @@ -49,7 +45,6 @@ # (range:forEach obj (fun (e) (print e))) # =end # @author https://github.com/SuperFola -### (let range:forEach (fun (_r _f) { (mut _val (_r)) (while (not (nil? _val)) { @@ -59,7 +54,6 @@ (_r.reset) })) -### # @brief Create a list based on a range and a filter function # @param _range the range object # @param _fun the filter function @@ -69,7 +63,6 @@ # (print (range:filter obj math:even)) # [2 4 6 8] # =end # @author https://github.com/SuperFola -### (let range:filter (fun (_range _fun) { (mut _value (_range)) (mut _output []) @@ -82,7 +75,6 @@ _output })) -### # @brief Create a list based on a range and a function to apply to each elements # @param _range the range object # @param _fun the function to apply @@ -92,7 +84,6 @@ # (print (range:map obj (fun (e) (* e e)))) # [1 4 9 16 25 36 49 64 81] # =end # @author https://github.com/SuperFola -### (let range:map (fun (_range _fun) { (mut _value (_range)) (mut _output []) @@ -105,7 +96,6 @@ _output })) -### # @brief Create a reduced list based on a range and a reduction function # @param _range the range object # @param _fun the reduction function @@ -115,7 +105,6 @@ # (print (range:reduce obj (fun (e) (+ e e)))) # 45 # =end # @author https://github.com/SuperFola -### (let range:reduce (fun (_range _fun) { (mut _output (_range)) (mut _last (_range)) @@ -125,4 +114,4 @@ }) (_range.reset) _output -})) \ No newline at end of file +})) diff --git a/String.ark b/String.ark index 1632fae..df8a777 100644 --- a/String.ark +++ b/String.ark @@ -1,5 +1,3 @@ -### -# @meta String # @brief Converts the given character to lowercase. # @param _string the string to make lowercase # @details The original string is left unmodified. @@ -9,7 +7,6 @@ # (let new (str:toLower message)) # => hello world, i like cheese # =end # @author https://github.com/SuperFola -## (let str:toLower (fun (text) { (mut _index 0) (mut _e "") @@ -28,7 +25,6 @@ _output })) -### # @brief Converts the given character to uppercase. # @param _string the string to make uppercase # @details The original string is left unmodified. @@ -38,7 +34,6 @@ # (let new (str:toUpper message)) # => HELLO WORLD, I LIKE CHEESE # =end # @author https://github.com/SuperFola -## (let str:toUpper (fun (_string) { (mut _index 0) (mut _e "") @@ -57,7 +52,6 @@ _output })) -### # @brief Reverse a string. # @param _string the string to reverse # @details The original string is left unmodified. @@ -67,7 +61,6 @@ # (let reversed (str:reverse message)) # => staog ekil I ,dlrow olleh # =end # @author https://github.com/Natendrtfm -## (let str:reverse (fun (_string) { (mut _index (- (len _string) 1)) (mut _returnedString "") @@ -78,7 +71,6 @@ _returnedString })) -### # @brief Get a slice of a given string, from a given index with a given length # @param _string the string to get a slice of # @param _startingIndex the index in the string where to start slicing @@ -90,7 +82,6 @@ # (let slice (str:slice message 6 4)) # => worl # =end # @author https://github.com/Natendrtfm -## (let str:slice (fun (_string _startingIndex _length) (if (= _length 0) "" @@ -109,7 +100,6 @@ }) )) -### # @brief Split a string in multiple substrings in a list, given a separator # @param _string the string to split # @param _separator the separator to use for splitting @@ -120,7 +110,6 @@ # (let splitted (str:split message " ")) # =end # @author https://github.com/Natendrtfm -## (let str:split (fun (_string _separator) { (assert (!= "" _separator) "Separator of split can not be empty") (assert (>= (len _separator) 1) "Separator length must be at least 1") @@ -141,7 +130,6 @@ (append _output _string)) })) -### # @brief Replace a substring in a given string # @param _string base string who contain pattern to replace by new sub string given # @param _pattern sub string pattern to replace @@ -152,7 +140,6 @@ # (let message "hello XXX, do you like the name XXX?") # (print (str:replace message "XXX" "Harry")) # hello Harry, do you like the name Harry? # =end -## (let str:replace (fun (_string _pattern _new) { (mut _out _string) (mut _idx (str:find _out _pattern)) @@ -168,7 +155,6 @@ _out })) -### # @brief Join a list of elements with a given string delimiter # @param _list host the elements to join # @param _delim a string delimiter to be put between each element @@ -178,7 +164,6 @@ # (let data [1 "hello" 3.14 true "world"]) # (print (str:join data ";")) # 1;hello;3.14;true;world # =end -## (let str:join (fun (_list _delim) { (mut _output "") (mut _index 0) @@ -189,4 +174,4 @@ }) _output -})) \ No newline at end of file +})) diff --git a/Switch.ark b/Switch.ark index 33cd5fe..27cd3bb 100644 --- a/Switch.ark +++ b/Switch.ark @@ -1,5 +1,3 @@ -### -# @meta Switch # @brief Takes a value to match against a list of [possible values, function to run if it matched] # @param _value value to match # @param _test list for test value, composed by sub lists who contained possible value and function to run if matched @@ -12,7 +10,6 @@ # ]) # =end # @author https://github.com/SuperFola -## (let switch (fun (_value _tests) { (mut _acc 0) (let _end (len _tests)) @@ -27,4 +24,4 @@ }) (set _acc (+ 1 _acc)) }) -})) \ No newline at end of file +})) diff --git a/os.ark b/os.ark index b437112..ac162fa 100644 --- a/os.ark +++ b/os.ark @@ -1,14 +1,12 @@ -### -# @meta os # @brief Returns the home dir of the current user # @author https://github.com/Wafelack, https://github.com/SuperFola -## -(let os:home_dir (fun () { - (if (or (= sys:platform "Linux") (= sys:platform "Mac OSX") (= sys:platform "Unix")) { - (let username (sys:exec "whoami")) - (if (= username "root\n") - "/root/" - (+ "/home/" username)) - } (if (= sys:platform "Windows") - (sys:exec "echo|set /p=%userprofile%"))) -})) \ No newline at end of file +(let os:home_dir (fun () + (if (or (= sys:platform "Linux") (= sys:platform "Mac OSX") (= sys:platform "Unix")) + { + (let username (sys:exec "whoami")) + (if (= username "root\n") + "/root/" + (+ "/home/" username)) + } + (if (= sys:platform "Windows") + (sys:exec "echo|set /p=%userprofile%")))))