![]() ![]() Should you choose to use a different Lisp implementation, the command to run Lisp code is different from what I use in this article ( gcl or sbcl instead of clisp, for example) but everything else is the same. On Fedora Linux: $ sudo dnf install clispįor macOS, you can use MacPorts or Homebrew: $ sudo port install clispįor Windows, you can either use clisp on Cygwin or download a GCL binary from gnu.org/software/gcl.Įven though I'm using the clisp command, most of the principles in this article apply to any Lisp. You can install any of these with your distribution's package manager, but for this article I use clisp. Popular open source versions include SBCL, GNU Lisp, and GNU Common Lisp (GCL). You might be surprised how much Lisp code there is lurking within big codebases in any given industry, so it's a good idea to have at least a passing familiarity with the language. Whether you love or hate its design philosophies, Lisp is an interesting glimpse at the past and, thanks to Clojure and Guile, into the future. People who love thinking about the aesthetics of programming languages often hate Lisp because of its frequent use of parentheses for scoping in fact, it's a common joke that Lisp stands for Lots of Irritating Superfluous Parentheses. People who love thinking about the design of programming languages often love Lisp because of how its syntax and data share the same structure: Lisp code is essentially a list of lists, and its name is an acronym for LISt Processing. eBook: An introduction to programming with Bash.Try for free: Red Hat Learning Subscription."Return the integer value of the natural number represented by RN. ![]() ((null (cdr RN)) (ro2ar (car RN))) stop recursion Its argument RN is wether a symbol, wether a list. "translate a roman number RN into arabic number. (Is this really the best way?) (defun ro2ar (RN) My solution: Write a wrapper function to convert a string into symbol or list of symbols as required for the funciton linked above. When dealing with web data, file names, or most other sources the roman numerals will most likely be in an Emacs Lisp string object. Unfortunately this function expects the number to be encoded as one Emacs Lisp symbol per digit, or a list of such symbol encoded digits. Here's the most applicable solution I found via a general web search: I decided it should be doable in Lisp, but if Emacs contains any function to do the conversion, I could not find it. Such numbers are not very useful for sorting and comparing with numbers in other forms. ![]() I gather data from all kinds of sources, and occasionally people use numbers written as roman numerals. Answers written as one or more Emacs Lisp functions would be ideal, thanks! I would like to accomplish this with Emacs Lisp, so I'm not expecting answers written as keyboard macros, other Lisp dialects, or shell scripts. In Emacs Lisp, how to write an Emacs Lisp function to convert a natural number from roman numerals representation to the equivalent Emacs Lisp integer value? The Emacs Lisp function should be callable from Emacs Lisp and return an Emacs Lisp integer object for further processing in an Emacs Lisp program. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |