Skip to content

Commit f4c9f95

Browse files
authored
Add Even Odd in Elvish (#4213)
1 parent 25dfe61 commit f4c9f95

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

archive/e/elvish/even-odd.elv

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use re
2+
3+
if (> 1 (count $args)) {
4+
echo "Usage: please input a number"
5+
exit 1
6+
}
7+
8+
if (not (re:match '^[+-]?[0-9]+(\.[0-9]+)?$' $args[0])) {
9+
echo "Usage: please input a number"
10+
exit 1
11+
}
12+
13+
if (== 0 (% $args[0] 2)) {
14+
echo Even
15+
} else {
16+
echo Odd
17+
}

0 commit comments

Comments
 (0)