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

Pages: 1-4041-

Halp how do i programmed scheme

Name: Anonymous 2007-03-26 12:29 ID:e6O5XmtL

I'm trying to make a program that prints out the contents of a list.

     (define (dumplist list)
          (car list)
          (cond (null? (cdr list))
               (else
                    (dumplist (cdr list)))))

However, this doesn't work. Instead it just prints (cdr list)

Name: Anonymous 2007-03-26 14:22 ID:7WQpQyCA

(define (display-list list)
  (when (not (null? list))
    (display (car list))
    (display #\space)
    (display-list (cdr list))))

Name: Anonymous 2007-03-26 16:22 ID:Mg9RfV9G

No that is terribly unscheme like, you should do:


(define (display-list list)
 (display "( ")
 (map (lambda (element)
              (if (not (list? element)) (display element)
                                        (display-list element))
              (display " ")) list)
 (display ")"))

Name: Anonymous 2007-03-26 16:32 ID:7WQpQyCA

>>3
How about (define display-list display)

Name: Anonymous 2007-03-26 16:38 ID:HUWoCYX5

No that is terribly unscheme like, you should do:

(define display-list display)

Name: Anonymous 2007-03-26 16:38 ID:HUWoCYX5

>>4
Fuck you. Forced reload of /prog/ should be enforced.

Name: Anonymous 2007-03-27 2:12 ID:sUdFqhmm

(No (that (is (terribly (unscheme (like, (you (should (do:)))))))))

Name: Anonymous 2007-03-27 3:29 ID:zxWKS6VA

showList = mapM_ print nigga

Name: Anonymous 2007-03-27 5:42 ID:iQX6ZJcP

>>7
(what (do (these (brackets (do?)))))

Name: Anonymous 2007-03-27 5:44 ID:r5o881yz

>>8
No that is terribly unscheme like, you should do:

(define display-list display)

Name: Anonymous 2007-03-27 11:04 ID:JfSuPvNl

If this were a Haskell, C#, C++ or Java thread, I'd troll by posting Python or Ruby for it. However, this thread is about Scheme, and I respect Scheme.

Name: Anonymous 2007-03-27 11:24 ID:ik4KyX44

>>11
Scheme is Haskell's retarded cousin.

Name: Anonymous 2007-03-27 12:01 ID:JfSuPvNl

>>12
Scheme is older than Haskell, and cleaner. You can actually learn it and finish learning it one day.

Name: Anonymous 2007-03-27 12:46 ID:ik4KyX44

>>13
Yes, that sucks.

Name: Anonymous 2007-03-27 16:29 ID:iQX6ZJcP

>>11
I respect a lot of things; doesn't stop me from trolling them. You obviously don't take your trolling seriously.

Name: Anonymous 2007-03-27 16:39 ID:qQoqVq3r

>>15
Depends on my mood, I've trolled Python, Lisp and Ruby as well.

Name: Anonymous 2007-03-30 2:27 ID:5O6yxmbE

Since I don't have an interpreter and XLisp doesn't want to download... I haven't tested this code

I actually never met "display" in Scheme... and the quoted parenthesis are not what professors expect. Someone else can probably check and expand on this idea below. You may need a final check for the empty list, because I'm not sure if it causes "more" of the list evaluated:

(define (dumplist list)
   (if (atom? list)
        'list # return the current value
        (dumplist (cdr list))  # recursion here to evaluate rest
   )
)

Name: Anonymous 2007-03-30 2:50 ID:uVzRbC/a

>>17 is an idiot

(define (dumplist list)
   (if (atom? list)
        'list # this returns the symbol "list" not the value of list
        (dumplist (cdr list))  # you are stupid
   ) # these do not go here
) ; lisp uses fucking semi colon for a comment you moron.

god I am disgusted GTFO (read SICP and STFU)

Name: Anonymous 2007-03-30 2:55 ID:gXVMcbhP

>>18
#what do these brackets do?#

Name: Anonymous 2007-03-30 4:39 ID:ia6UjUH+

(define (display-list list) map display list)

lol

Name: Anonymous 2007-03-30 4:46 ID:Heaven

My other car is a cdr.

Name: Anonymous 2007-03-30 7:55 ID:uVzRbC/a

>>20
you mean
(define (display-list list) (map display list))

YOU FUCKING IDIOT

Name: Anonymous 2007-03-30 13:04 ID:ia6UjUH+

>>22
No I don't, you fucking moron. I don't want the list of voids to be evauluated. GB2/C++/ n00b.

Name: Anonymous 2007-03-30 13:11 ID:iBqSc0vu

>>20
>>22
You sick fucks are using `list' as a variable name. GB2CL.

Name: Anonymous 2007-03-30 13:16 ID:cjFuaLWK

>>24
LEXICAL SCOPING MOTHERFUCKER, DO YOU KNOW IT?

Name: Anonymous 2007-03-30 13:35 ID:yF1ruKsI

>>25
ONE LETTER VARIABLE NAMES MOTHER FUCKER, DO YOU USE THEM?

Name: Anonymous 2007-03-30 13:40 ID:76555Z9P

>>24
Boohoo. If I'm not using the list function I can happily shadow it.

Name: Anonymous 2007-03-30 14:00 ID:VQefRdKW

>>27
how do i wrote convoluted code?

Name: Anonymous 2007-03-30 14:25 ID:uVzRbC/a

LOOOOOL
ONE WORD FORCED PARANTHESIS AROUND CODE, THREAD OVER!

Name: Anonymous 2007-03-30 15:17 ID:76555Z9P

>>28
Surely it's more convoluted to make sure none of your variable names shadow any library functions that you're not using anyway. Tard.

Name: Anonymous 2007-03-30 23:39 ID:3SStrPYL

One word, forced parenthesis around code. Thread over.

Name: Anonymous 2007-03-30 23:45 ID:5O6yxmbE

What a blast this has turned into. I ALMOST forgive the bashing of my #17 code. But I'm ANONYMOUS, MOTHERFUCKERS!! :)
And nobody has really given a non-library solution to this shit. The prof. will be angry at the OP for using superiarrr code so early in the semester.

Name: Anonymous 2007-03-31 4:49 ID:EjOiRxIW

>>30

#;> (define (frest list)
        (car list))
#;> (frest '(a b c))
a

Name: Anonymous 2007-03-31 12:47 ID:hTrr49Zg

(define (cons a b)
  (lambda (f) (f a b)))

(define (car x)
  (x (lambda (a b) a)))

(define (cdr x)
  (x (lambda (a b) b)))


Who needs data structures when you have lexically scoped first class functions?

Name: Anonymous 2007-03-31 12:56 ID:GTO0cVRR

>>34
What does this have to do with the topic? Or is this just your way to say "I've read SICP"?

Name: Anonymous 2007-03-31 14:12 ID:EjOiRxIW

>>35
What does this have to do with the topic? Or is this just your way to say "I've read SICP"?

Name: Anonymous 2007-03-31 15:12 ID:hTrr49Zg

>>35
What does ANYTHING in this topic have to do with the topic?

Name: Anonymous 2007-03-31 15:15 ID:GTO0cVRR

>>37
The OP posted a nonsensical piece of useless Scheme code and the rest followed with variations of the same theme. >>34 is actually a pretty cool thing.

Name: Anonymous 2009-01-14 14:49

Trolls

Name: Anonymous 2010-11-25 7:38

Name: Anonymous 2011-02-04 13:50

Name: Anonymous 2012-03-25 9:35

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

Name: Anonymous 2012-04-03 19:17

#lang racket

(define (flip f)
  (lambda (x y)
    (f y x)))

(define list->strings
  (curry map (compose (curry (flip
                              string-append) "\n")
                      (lambda (x)
                        (match x
                          [number (number->string x)]
                          [x x])))))

(define dump-list (compose
                   (curry (flip string-join) "")
                   list->strings))

(display (dump-list '(1 2 3 4)))

Name: Anonymous 2012-04-03 19:32

>>44

oops, sorry that doesn't work -- better version

#lang racket

(define (flip f)
  (lambda (x y)
    (f y x)))

(define list->strings
  (curry map (compose (curry (flip
                              string-append) "\n")
                      (lambda (x)
                        (match x
                          [(? number?) (number->string x)]
                          [(? string?) x]
                          [list (dump-list x)])))))

(define dump-list (compose
                   (curry (flip string-join) "")
                   list->strings))

(display (dump-list (list 1 2 3 "sup" (list 1 2 3))))

Name: Anonymous 2012-04-04 13:58

>>45
)])))))
Elegant my ass.

Name: Anonymous 2012-04-04 19:21

))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

Name: Anonymous 2012-04-04 19:28

All play and no work makes Jack a mere toy!

Name: Anonymous 2012-04-04 19:50

>>48

All work and no play makes Jack a dumb goy!

Name: sage 2012-04-05 2:46

GC is shit.

Name: Sgt.Kabu塐䕫kimanᒷ豼 2012-05-28 23:44

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

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