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

Pages: 1-

Scheme/Racket

Name: Anonymous 2012-11-19 14:07

Can someone explain this shit to me?


CODE
(define insertion-sort
  (lambda (lst)
    (if (null? lst)
        '()
        (insert (car lst)
                (insertion-sort (cdr lst))))))

(define insert
  (lambda (elt sorted-lst)
    (if (null? sorted-lst)
        (list elt)
        (if (<= elt (car sorted-lst))
            (cons elt sorted-lst)
            (cons (car sorted-lst)
                  (insert elt (cdr sorted-lst))))))))
 

 RESULT
(insertion-sort '(5 9 8 4 2))
(2 4 5 8 9)

Name: Anonymous 2012-11-19 15:03

What part don't you understand exactly?

If you don't get how Lisp expressions return values, then obviously you won't know why the control flow is written the way it is. But there are a lot of other things to not get about this code. Please narrow it down.

Name: Anonymous 2012-11-19 23:49

>>1

insertion-sort sorts le list and insert inserts le elt into le sorted list.

Name: Anonymous 2012-11-20 0:01

This would be three lines in C and not look like dick.

Name: Anonymous 2012-11-20 1:19

>>4
HEY functional programming is very expressive. You shut your whore mouth, BITCH!

Name: Anonymous 2012-11-20 2:17

Optimize your function definitions, Ahmed.

Name: noko 2012-11-20 3:33

>>4

>anything taking three lines in C
>anything in C not looking like dick.

Name: Anonymous 2012-11-20 3:35

>>7
Back to le /g/redditnews, shitstain.

Name: Anonymous 2012-11-20 5:40

isort :: (Ord a) => [a] -> [a]
isort [] = []
isort (x:xs) = ins x (isort xs)

ins :: (Ord a) => a -> [a] -> [a]
ins x [] = [x]
ins x (y:ys)
    | x <= y    = x : y : ys
    | otherwise = y : ins x ys

Name: Anonymous 2012-11-20 5:57

>>11 noice derbz

Name: Anonymous 2012-11-20 5:58

NIGGERs

Name: Anonymous 2012-11-20 7:51

I'm gonna need the Symta of this too.

Name: Anonymous 2012-11-20 8:45

>>8
C is undefined shit, faggot.

Name: Anonymous 2012-11-20 10:32

>>12
Symta:
f l @ . $ ! [-] a - + / 54adsfasdfasdfadsf

Name: Anonymous 2012-11-20 12:56

>>14
What happened to the Symta implementation of WC2?

Name: Anonymous 2012-11-20 14:28

>>14
optimized symta:

סוג הכניסה ( ͡° ͜ʖ ͡°)

Name: Anonymous 2012-11-20 14:50

>>16
( ͡° ͜ʖ ͡°) le /frog/ face

Name: Anonymous 2012-11-20 15:36

( ͜° ʖ ͜°)

Name: ( ͡° ͜ʖ ͡°) 2012-11-20 15:45

( ͡° ͜ʖ ͡°)

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