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

Sublists in Scheme/Racket

Name: Anonymous 2012-11-08 15:50

/prog/

What am I doing wrong here?

I'm supposed to make a Scheme/Racket function named "sublist?" that takes 2 lists of numbers. It is supposed to produce true if list1 is a sublist of list2 (in other words, list 2 contains list1) and false if its otherwise.

But this shit ain't working...

 (define (sublist? l1 l2)
  (cond ((null? l2) #t)
        ((not (exists l1 (car l2))) #f)
        (else (sublist? l1 (cdr l2)))))
 
 (define (exists l p)
  (if (null? l) #f
      (or (equal? p (car l)) (exists (cdr l) p))))

Name: Anonymous 2012-11-08 18:03

>>13
Ahmed is a computer science genius, born in some obscure caucasian republic of the Russian Federation. He became familiar with the work of Konrad Zuse at the age of 8, when he found a bunch of papers that were stolen in the rampaging of Berlin by his grandfather, Murat.

Self-taught, ignorant of (and aggressively opposed to) mathematical abstractions, his incredible talent wasn't left unnoticed and Ahmed was offered a job at the Russian Supercomputer Center of Atomic Weapon.

His vivid antisemitism got him fired in 2002 when a partnership with the Israeli Supercomputer Center of Atomic Weapon was signed.

Retired early, living of social welfare, Ahmed now dedicates himself to Symta, the revolutionary language he created.

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