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

Pages: 1-

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 16:11

use newLISP.

Name: Anonymous 2012-11-08 16:18

newLISP:


(define (sublist? l1 l2) (= (union l1 l2) l2))


Where's your god now?

Name: Anonymous 2012-11-08 16:21

You swapped l1 and l2.

Name: Anonymous 2012-11-08 16:21

>>3
works if the input list are all sorted. an improvement:

(define (sublist? l1 l2) (= (sort (union l1 l2)) (sort l2)))


Done. back to fucking Touhous.

Name: Anonymous 2012-11-08 16:23

>>5
forgot to mention, error checking for empty lists is left as an exercise for >>1-kun

Name: Anonymous 2012-11-08 16:25

>>2
>>3
>>5
Unfortunately, I cannot use newLISP.

Name: Anonymous 2012-11-08 16:25

>>5
Terrible!

Name: Anonymous 2012-11-08 16:26

>>7
Is that you, Ahmed?

Name: Anonymous 2012-11-08 16:26

>>9
Who the fuck is Ahmed?

Name: Anonymous 2012-11-08 16:42

Name: Anonymous 2012-11-08 16:53

>>11
He looks cool. I'd go for a coffee with him.

Name: Anonymous 2012-11-08 16:55

>>10
The guy who never optimizes his quotes and spreads lies about the Jewish people.

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.

Name: Anonymous 2012-11-08 18:26

>>14
Now it all makes sense.

Name: Anonymous 2012-11-08 18:28

Ahmed now dedicates himself to Symta, the revolutionary language he created.
and that sandnigger won't document his allah ackbar salami boom mystical ``programming language''

Name: Anonymous 2012-11-08 20:11

is every element of l1 in l2?

(define subset?
  (lambda (l1 l2)
    (foldr (lambda (t b) (and b (member? t l2))) #t l1)))

i'll let you figure out member? on your own

Name: Anonymous 2012-11-09 3:35

Bump.

Name: Anonymous 2012-11-09 3:44

>>16

You remind me of the jews poster more and more everyday. The same use of quotations for mocking. Character assassination. Trying to find out details for a character to assassinate when the character is presented from behind the murks of an anonymous bbs. And ironically, you show the same bigotry as well. I'm reminded of neo and agent smith from the matrix.

Name: Anonymous 2012-11-09 6:00

>>19
Ahmed is Goldberg, Goldberg is Ahmed.

Name: Anonymous 2012-11-09 7:16

SEX PRESS ION

Name: Islamic Republic of Iran 2012-11-09 7:32

>>14
Ahmed is welcome to join our scientists at the Iranian Supercomputer Center for Atomic Weapon.
Unless he's afraid of Tsahal hitmen, of course.

Name: Anonymous 2012-11-09 14:38

Bump.

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