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

Pages: 1-

Recursion

Name: Anonymous 2011-03-26 22:06

Explain the essence of recursion in one line

Name: Anonymous 2011-03-26 22:08

>>2

Name: Anonymous 2011-03-26 22:13

>>1-2
Probably the same person, but I enjoyed it nonetheless.

Name: Anonymous 2011-03-26 22:16

Prelude> let fact n = if n == 1 then 1 else n * fact (n - 1)
Prelude> fact 5
120
Prelude>

Name: Or_better_yet 2011-03-26 22:21

let fact n = if n == 0 then 1 else n * fact (n - 1)

Name: Anonymous 2011-03-26 22:58

>>2
no base case; the function would never end

Name: Anonymous 2011-03-26 23:10

>>3,4

(define small-odd-swing
  (vector 1 1 1 3 3 15 5 35 35 315 63 693 231 3003 429 6435 6435 109395
          12155 230945 46189 969969 88179 2028117 676039 16900975 1300075
          35102025 5014575 145422675 9694845 300540195 300540195))

(define (swing n)
  (if (< n 33) (vector-ref small-odd-swing n)
      (let* ((primes (sieve (range 3 n #:by 2)))
             (rootn (integer-sqrt n))
             (primesa (take-while (curryr <= rootn) primes))
             (primesb (filter (λ (x) (odd? (quotient n x)))
                                 (take-while (curryr <= (quotient n 3))
                                             (drop-while (curryr <= rootn) primes)))))
        (apply
         *
         (append
          (map
           (λ (prime)
             (do ((q (quotient n prime) (quotient q prime))
                  (p 1 (if (odd? q) (* p prime) p)))
               ((zero? q) p)))
           primesa)
          (take-while (curryr <= n)
                      (drop-while (curryr <= (quotient n 2)) primes))
          primesb)))))

(define (rec-fact n)
  (if (< n 2) 1
      (* (expt (rec-fact (quotient n 2)) 2) (swing n))))

(define (fact n)
  (if (< n 20) (Π values 1 n)
      (arithmetic-shift (rec-fact n) (- n (bitwise-bit-count n)))))

Name: Anonymous 2011-03-26 23:11

please read >>8 to understand recursion

Name: Anonymous 2011-03-27 0:53

GNU

Name: Anonymous 2011-03-27 0:56

>>9
What does the ``G'' in GNU stand for?

Name: Anonymous 2011-03-27 1:16

>>10
It stands for GNU, which in turn stands for GNU's Not Usable.

Name: Anonymous 2011-03-27 1:22

Have you ever been dreaming that you were dreaming?

Name: Anonymous 2011-03-27 2:56

I once dreamed that I was recursing.

Name: Anonymous 2011-03-27 5:02

I once dreamed of cocks drifting across the blue sky.

Name: Anonymous 2011-03-27 7:37

>>11

That's not recursive, the G expands to GNU's.

Name: Anonymous 2011-03-27 22:08

YHBT, which stands for YHBT has been trolled.

Name: Anonymous 2011-03-27 22:11

>>16
What does the ``YHBT'' in ``YHBT'' stand fostack overflow

Name: Anonymous 2011-03-27 22:21

>>17
STANDS FOR MY ANUS

Name: Anonymous 2011-03-28 0:47

Please return to the start of this sentence.

Name: Anonymous 2011-03-28 7:29

>>19
i like this one!

Name: Anonymous 2011-03-28 7:50

>>19
PLEASE RETURN TO MY ANUS

Name: Anonymous 2011-03-28 8:41

go back to /prog/, ``please''

Name: Anonymous 2011-03-28 8:45

This sentence explains recur***Exception: Stack pointer monadic oberlow

Name: Anonymous 2011-03-28 9:10

Recursion is like fucking yourself in your own peehole.

Name: Anonymous 2011-03-28 9:23

>>24
The base case is the pleasure of being cummed inside

Name: Anonymous 2011-03-28 9:48

>>6
It ends when you understand.

Name: Anonymous 2011-03-28 10:40

If you understand recursion, get out this thread, if not, read post >>27

Name: Anonymous 2011-03-28 10:51

>>27
Nice tail recursion.

Name: Anonymous 2011-03-28 11:31

Masturbation

Name: Anonymous 2011-03-28 11:58

>>28
Does Shiichan optimize tail calls?

Name: Anonymous 2011-03-28 12:01

>>30
It doesn't even optimise [b][u][i][o] to [expert], so I reckon it was invoked with -O1 or less.

Name: Anonymous 2011-03-28 12:10

>>31
At least it optimizes near quotes.

Name: Anonymous 2011-03-28 14:09

>>31
So if you pass a negative number to -O, the compiler will bloat the code instead?

Name: Anonymous 2011-03-28 14:18

>>33
YES, I COMPILED THIS WITH -O-03

Now look at the HTML.

Name: Anonymous 2011-03-28 15:04

Name: Anonymous 2011-03-28 15:08

>>35
No far quotes for you, imageboarder.

Name: Anonymous 2011-03-28 21:53

[expert]derp[/expert]

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