Palindromic Number in Elvish

Published on 16 January 2025 (Updated: 16 January 2025)

Welcome to the Palindromic Number in Elvish page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

use str

fn die {
  echo 'Usage: please input a non-negative integer'
  exit 1
}

if (> 1 (count $args)) {
  die
}

var n = $args[0]

# Check if the number contains a decimal point
if (str:contains $n .) {
  die
}

try {
  var q = (+ $n 1)
} catch _ {
  die
}

if (> 0 $n) {
  die
}

if (eq $n (echo $n|rev)) {
  echo true
} else {
  echo false
}

Palindromic Number in Elvish was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.