Displaying a string while using cond in Lisp -


i'm starting off lisp , need help. technically homework, gave try , getting wanted:

(defun speed (kmp)     (cond ((> kmp 100) "fast")             ((< kmp  40) "slow")          (t           "average"))) 

however, if run program displays "average" instead of average (without quotes).

how can display string without quotes?

you can use symbols instead of strings:

(defun speed (kmp)     (cond ((> kmp 100) 'fast)             ((< kmp  40) 'slow)          (t           'average))) 

symbols uppercased default, internally fast fast.

you can write symbol in case , characters using escaping vertical bars:

|the speeed fast!| 

above valid symbol in common lisp , stored internally write case preserved.


Comments

Popular posts from this blog

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -

openssl - Load PKCS#8 binary key into Ruby -