![]() ![]() Reverse each string in a list of strings 3. Count the number of elements in a list 2. (concatenate 'string (subseq word 1) (subseq word 0 1) "ay")))) Creating Dialogue Boxes Writing Programs Processing Items in a List 1. (string= initial "i") (string= initial "o") (or (string= initial "a") (string= initial "e") ![]() Write a piglatin translator (defun piglatin (word) Test whether an object is a list of two numbers 3. (concatenate 'string (subseq str places) (subseq str 0 places))) Printing Testing a Result 1. ![]() Rotate a string n places to the left (defun rotate (str places) Or without using length: (defun midverse (word) (reverse (subseq word 1 (- (length word) 1))) Reverse the middle letters of a word (defun midverse (word) Return the last item in a list (defun last-elt (lst) Return a random item from a list (defun random-elt (lst) Duplicate the first item in a list (defun dup (lst) (cons (second lst) (cons (first lst) (rest (rest lst))))) 2. Swap the first two items in a list (defun swap (lst) ![]() Substitute values into a quadratic equation (defun pseudo-primes (x) Cube the sum of two numbers (defun cubesum (a b)Īnswer)) 4. Find the average of three numbers (defun average3 (number1 number2 number3) Convert between km and miles (defparameter kilometresinmiles 0.621371192) Find the result of throwing two dice (defun two-dice () Find the nth triangular number (defun triangular (n) (list 1 (list 2 (list 3 4))) Expressions Defining Procedures 1. "Return the integer value of the natural number represented by RN.Not all the exercises have answers yet. ((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 |