Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

imrove how to ?

Name: Anonymous 2007-08-25 12:37 ID:E46Uz0+j

I write a defun in LISP because replace all SEARCHES with REPLACES e.g.

"Go kawari haku fun" '("kaw" "hak") '("hak" "kaw")
into
"Go hakari kawu fun"

This its:


(defun search-and-replace (string search[es] replace[s])
  (let ((index
         (position-if #'(lambda (search)
                          (and (> (length string) (length search))
                               (string= string search :end1 (length search))))
                      search[es])))
    (cond (index
           (concatenate 'string
                        (elt replace[s] index)
                        (search-and-replace
                         (subseq string (length (elt search[es] index)))
                         search[es] replace[s])))
          ((string/= "" string)
           (concatenate 'string
                        (subseq string 0 1)
                        (search-and-replace
                         (subseq string 1)
                         search[es] replace[s])))
          (t ""))))



And how did you improved? Thanks.

Name: Anonymous 2007-08-25 12:44 ID:Heaven

I can help you in Scheme;
nobody uses Lisp nowadays.

Name: Anonymous 2007-08-25 12:48 ID:Heaven

>>2
Scheme is a lisp.

Name: Anonymous 2007-08-25 12:50 ID:Heaven

>>3
A variety of Lisp, a dialect, not pure Lisp.

Name: Anonymous 2007-08-25 13:45 ID:Heaven

>>4
The only `pure' Lisp is the McCarthy one. Since the '60s, the only relevant meaning of `Lisp' has been the family of languages (`dialects, varieties', if you wish) directly influenced by McCarthy's original Lisp. Scheme is a Lisp.

Name: Anonymous 2007-08-25 18:25 ID:E46Uz0+j

And you have anything to say for my code?

Name: Anonymous 2011-02-04 19:52

Don't change these.
Name: Email:
Entire Thread Thread List