• .re: Please help

    From Robert L.@21:1/5 to Private Oracle on Mon Mar 7 09:27:35 2022
    "Private Oracle" wrote:

    I'm new to LISP and I've got a real bugger of
    a problem here : I need to define a function
    which duplicates every occurance of a given
    element in a given list. Suppose this funtion
    was called DUPLIC8, then the call

    (DUPLIC8 '(A B C D E B) 'B))

    should produce (A B B C D E B B).

    Gauche Scheme or Racket:

    (define (duplic8 items which)
    (append-map
    (lambda (x)
    (if (equal? x which)
    (list x x)
    (list x)))
    items))

    (duplic8 '(a b c b) 'b)
    ===>
    (a b b c b b)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)