Skip to main content
Code Review

Return to Question

deleted 7 characters in body; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

remove Remove first occuranceoccurrence of element from list

As explained here i'm, I'm learning a limited subset of schemeScheme.

My task has been to sort a numerical list. ToTo implement a simple insertion sort, iI need to remove a single element from a list.

I've done the following (in the spirit of The Little Schemer):

(define remove-elem
 (lambda (ll elem)
 (cond
 ((null? ll) '())
 ((eq? (car ll) elem) (cdr ll))
 (else 
 (cons (car ll) (remove-elem (cdr ll) elem))))
 ))

What are the other ways of implementing this function?

remove first occurance of element from list

As explained here i'm learning a limited subset of scheme.

My task has been to sort a numerical list. To implement a simple insertion sort, i need to remove a single element from a list.

I've done the following (in the spirit of The Little Schemer)

(define remove-elem
 (lambda (ll elem)
 (cond
 ((null? ll) '())
 ((eq? (car ll) elem) (cdr ll))
 (else 
 (cons (car ll) (remove-elem (cdr ll) elem))))
 ))

What are the other ways of implementing this function?

Remove first occurrence of element from list

As explained here , I'm learning a limited subset of Scheme.

My task has been to sort a numerical list. To implement a simple insertion sort, I need to remove a single element from a list.

I've done the following (in the spirit of The Little Schemer):

(define remove-elem
 (lambda (ll elem)
 (cond
 ((null? ll) '())
 ((eq? (car ll) elem) (cdr ll))
 (else 
 (cons (car ll) (remove-elem (cdr ll) elem))))
 ))

What are other ways of implementing this function?

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

As explained here here i'm learning a limited subset of scheme.

My task has been to sort a numerical list. To implement a simple insertion sort, i need to remove a single element from a list.

I've done the following (in the spirit of The Little Schemer)

(define remove-elem
 (lambda (ll elem)
 (cond
 ((null? ll) '())
 ((eq? (car ll) elem) (cdr ll))
 (else 
 (cons (car ll) (remove-elem (cdr ll) elem))))
 ))

What are the other ways of implementing this function?

As explained here i'm learning a limited subset of scheme.

My task has been to sort a numerical list. To implement a simple insertion sort, i need to remove a single element from a list.

I've done the following (in the spirit of The Little Schemer)

(define remove-elem
 (lambda (ll elem)
 (cond
 ((null? ll) '())
 ((eq? (car ll) elem) (cdr ll))
 (else 
 (cons (car ll) (remove-elem (cdr ll) elem))))
 ))

What are the other ways of implementing this function?

As explained here i'm learning a limited subset of scheme.

My task has been to sort a numerical list. To implement a simple insertion sort, i need to remove a single element from a list.

I've done the following (in the spirit of The Little Schemer)

(define remove-elem
 (lambda (ll elem)
 (cond
 ((null? ll) '())
 ((eq? (car ll) elem) (cdr ll))
 (else 
 (cons (car ll) (remove-elem (cdr ll) elem))))
 ))

What are the other ways of implementing this function?

Source Link
ricardo
  • 265
  • 4
  • 10

remove first occurance of element from list

As explained here i'm learning a limited subset of scheme.

My task has been to sort a numerical list. To implement a simple insertion sort, i need to remove a single element from a list.

I've done the following (in the spirit of The Little Schemer)

(define remove-elem
 (lambda (ll elem)
 (cond
 ((null? ll) '())
 ((eq? (car ll) elem) (cdr ll))
 (else 
 (cons (car ll) (remove-elem (cdr ll) elem))))
 ))

What are the other ways of implementing this function?

lang-lisp

AltStyle によって変換されたページ (->オリジナル) /