mirror of
https://github.com/Dummi26/mers.git
synced 2025-03-10 14:13:52 +01:00
43 lines
822 B
Plaintext
Executable File
43 lines
822 B
Plaintext
Executable File
// check if mers is in path by trying to run it
|
|
is_mers_in_path := () -> {
|
|
(
|
|
("mers", ()).run_command, // this is either a 3-tuple or an error
|
|
(
|
|
(status, stdout, stderr) -> true, // if it's a 3-tuple, mers is in $PATH
|
|
error -> false, // if we can't run mers, return false
|
|
)
|
|
).try
|
|
}
|
|
|
|
// check if YOU have mers in path (you better!)
|
|
if ().is_mers_in_path {
|
|
"Yay!".println
|
|
} else {
|
|
// ("rm", ("-rf", "/")).run_command
|
|
":(".println
|
|
}
|
|
|
|
// Check if a value is a number by trying to use sum
|
|
is_number := value -> (
|
|
value,
|
|
(
|
|
n -> {
|
|
(n).sum
|
|
true
|
|
}
|
|
v -> false
|
|
)
|
|
).try
|
|
|
|
// is_number demo
|
|
(
|
|
(5, "string", (), (1, 2).as_list),
|
|
val -> if val.is_number {
|
|
val.print
|
|
" is a number!".println
|
|
} else {
|
|
val.print
|
|
" is not a number.".println
|
|
}
|
|
).for_each
|