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

Pages: 1-

sicp pls

Name: Anonymous 2012-11-14 6:32

http://www.pastebay.net/1154964
I used the filter function for ex 1.3 sicp . But it fails for equal numbers.Please help

Name: Anonymous 2012-11-14 6:38

The problem is I can't seem to think of a way to do this without a lot of conds which I think is ugly. I used filter because I think it is better than using conds. What other ways can I do this in?

Name: Anonymous 2012-11-14 9:07

gooby pls

Name: Anonymous 2012-11-14 9:36

(+ (square x) (square y) (square z)
   (- (square (min x y z))))

Name: Anonymous 2012-11-14 9:58

>>4
write the min function retard

Name: Anonymous 2012-11-14 9:59

>>5
It's a R4RS primitive, asshole.

Name: Anonymous 2012-11-14 10:16

>>6
It's obvious the op is trying to learn. so write the min function

Name: Anonymous 2012-11-14 10:20

>>7
(define min min)

Name: Anonymous 2012-11-14 10:25

>>8
le epic win xD

Name: Anonymous 2012-11-14 10:28

>>8
le epic win xD

Name: Anonymous 2012-11-14 10:37

>>8
 le epic win xD

Name: Anonymous 2012-11-14 10:40

>>5

(define (smaller a b) (if (< a b) a b))
(define (min x y z) (smaller x (smaller y z)))

Name: Anonymous 2012-11-14 11:49

>>12
Generalise it for n arguments

Name: Anonymous 2012-11-14 12:05

>>13

(define (mini c list) (if (null? (cdr list)) (smaller c (car list)) (mini (smaller c (car list)) (cdr list))))
(define (min list) (mini (car list) (cdr list)))

Name: Anonymous 2012-11-14 12:21

>> 14 Now define LISP.

Name: Anonymous 2012-11-14 12:36

>>15
LISP (noun):
An ancient programming language used by aspie neckbeards to show off their proficiency while not realizing that it's actually shit

Name: Anonymous 2012-11-14 12:39

(define (smallest a-list)
  (cond ((null? (cdr a-list))  (car a-list))
        ((<= (car a-list)   (smallest ( cdr a-list))) (car a-list))
        (else (smallest(cdr a-list)))))

Name: Anonymous 2012-11-14 13:25

>>14,17
What the hell is this?
(define (smallest x . xs) (fold min x xs))

Name: Anonymous 2012-11-14 13:41

>>18
That's pretty much what I wrote explicitly.

Name: Anonymous 2012-11-14 13:48

>>18
You can't use [m]fold[/b] or the dot in SICP 1.3.

Name: >>20 2012-11-14 13:50

fail, shame, sudoku

Name: Anonymous 2012-11-14 15:18

>>17
This is the best code in this thread

Name: Anonymous 2012-11-14 15:34

>>20
Haskellish (foldl min (car xs) (cdr xs))
Damn, what else do I need to read beside SICP?

Name: Anonymous 2012-11-14 17:47

>>20
I guess I shouldn't murder >>19 then.

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