How to resolve the algorithm Show ASCII table step by step in the Common Lisp programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Show ASCII table step by step in the Common Lisp programming language
Table of Contents
Problem Statement
Show the ASCII character set from values 32 to 127 (decimal) in a table format.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Show ASCII table step by step in the Common Lisp programming language
Source code in the common programming language
(setq startVal 32)
(setq endVal 127)
(setq cols 6)
(defun print-val (val) "Prints the value for that ascii number"
(cond
((= val 32) (format t " 32: SPC "))
((= val 127) (format t "127: DEL~%"))
((and (zerop (mod (- val startVal) cols)) (< val 100)) (format t "~% ~d: ~a " val (int-char val)))
((and (zerop (mod (- val startVal) cols)) (>= val 100)) (format t "~%~d: ~a " val (int-char val)))
((< val 100) (format t " ~d: ~a " val (int-char val)))
((>= val 100) (format t "~d: ~a " val (int-char val)))
(t nil)))
(defun get-range (lower upper) "Returns a list of range lower to upper"
(if (> lower upper) '() (cons lower (get-range (+ 1 lower) upper))))
(mapcar #'print-val (get-range startVal endVal))
You may also check:How to resolve the algorithm Extend your language step by step in the Perl programming language
You may also check:How to resolve the algorithm Infinity step by step in the BASIC programming language
You may also check:How to resolve the algorithm Nonogram solver step by step in the Wren programming language
You may also check:How to resolve the algorithm Constrained random points on a circle step by step in the ZX Spectrum Basic programming language
You may also check:How to resolve the algorithm Generic swap step by step in the LiveCode programming language