We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e608cff commit acca088Copy full SHA for acca088
archive/e/elvish/palindromic-number.elv
@@ -0,0 +1,33 @@
1
+use str
2
+
3
+fn die {
4
+ echo 'Usage: please input a non-negative integer'
5
+ exit 1
6
+}
7
8
+if (> 1 (count $args)) {
9
+ die
10
11
12
+var n = $args[0]
13
14
+# Check if the number contains a decimal point
15
+if (str:contains $n .) {
16
17
18
19
+try {
20
+ var q = (+ $n 1)
21
+} catch _ {
22
23
24
25
+if (> 0 $n) {
26
27
28
29
+if (eq $n (echo $n|rev)) {
30
+ echo true
31
+} else {
32
+ echo false
33
0 commit comments