Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!barmar From: barmar@think.com (Barry Margolin) Newsgroups: comp.lang.lisp Subject: Re: Is MAP meant to operate on strings? Message-ID: <1991Feb23.220923.10748@Think.COM> Date: 23 Feb 91 22:09:23 GMT References: <1991Feb23.205613.14321@magnus.ircc.ohio-state.edu> Sender: news@Think.COM Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 28 In article <1991Feb23.205613.14321@magnus.ircc.ohio-state.edu> murthy@magnus.ircc.ohio-state.edu (Murthy S Gandikota) writes: >(map 'string #'(lamda (x) (if (equal x #\e) #\f)) "I want to replace e >with f") > >==> Error: ARG not a character > >(this is all the error informatin my LISP machine displays) Must not be a Symbolics Lisp Machine. After I fix the misspelling of "lambda", mine says: Trap: The first argument given to the SYS:CHAR-LDB-INTERNAL instruction, NIL, was not a character. The problem is that your function returns NIL when the character isn't #\e, and NIL isn't a valid element of a string. You should have it return its argument: #'(lambda (x) (if (char-equal x #\e) #\f x)) By the way, you might want to replace this with SUBSTITUTE: (substitute #\f #\e "I want to replace e with f") -- Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar