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

IT HAPPENED AGAIN

Name: Anonymous 2009-08-02 9:16

I spontaneously learned Javascript when /prog/ was down!

Name: Anonymous 2009-08-02 9:28

You learned Javascript twice!?

Name: Anonymous 2009-08-02 9:31

>>2
No, last time I learned PHP!

Name: Anonymous 2009-08-02 9:31

Holy crap, I'm talking like an anus.

Name: Anonymous 2009-08-02 9:42

>>1
U MENA HASKAL
Ahh, that was refreshing, I missed that.

Name: Anonymous 2009-08-02 10:51

>>4
>>5
cancer that is killing /prog/

Name: Anonymous 2009-08-02 15:15

Maintenance my ANUS!

Name: Anonymous 2009-08-02 15:25

>>6
U MENA HAX MAH ANUS

Name: Anonymous 2009-08-02 15:26

>>7
There were no mentions of maintenance in this thread, what are you doing?

Name: Anonymous 2009-08-02 15:32

>>9
Scheduled maintenance to be performed tonight (7/29) and tomorrow (7/30). Total downtime should not exceed more than a few hours.2:12 PM Jul 29th from web
http://twitter.com/4chan

__________________________________________
http://xs135.xs.to/xs135/09042/av922.jpg
Velox Et Astrum gamedev forum: http://etastrum.phpbb3now.com
There are two kinds of scientific progress: the methodical experimentation and categorization which gradually extend the boundaries of knowledge, and the revolutionary leap of genius which redefines and transcends those boundaries. Acknowledging our debt to the former, we yearn, nonetheless, for the latter.

Name: Anonymous 2009-08-02 20:43

I was so happy to see /prog/ back that I wrote a fibs.  I hope you like it :).

module Fibs where
import Data.Function
import Control.Arrow

fibs = fix$ (1:).(1:).uncurry (zipWith (+)).(id &&& tail)

Name: Anonymous 2009-08-02 20:47

I don't like it you fucking tit

Name: Anonymous 2009-08-02 21:01

:(

Name: Anonymous 2009-08-02 21:07

that's some short fibs, gj

Name: !MILKRIBS4k 2009-08-02 21:08

I have been thinking of learning javascript actually, I know a little but getting a firm grip of it could really help my web dev skills!

Name: Anonymous 2009-08-02 22:02

Here's my go at some fibs in CL:

Start off with the most basic version:

(defun fibs (n)
  (case n
    (0 0)
    (1 1)
    (2 1)
    (t (+ (fibs (- n 2)) (fibs (- n 1))))))

(fibs 35);=>9227465
(time (fibs 35))
;Evaluation took:
;  0.328 seconds of real time
;  0.328125 seconds of total run time (0.328125 user, 0.000000 system)
;  100.00% CPU
;  785,917,755 processor cycles
;  4,096 bytes consed

Works, but it's inefficient as hell since previous needed values get evaluated repeatedly.

Let's try some memoization:

;;; PG's memoize function. It's very simple, has some shortfalls, but enough for this example.
(defun memoize (fn)
  (let ((cache (make-hash-table :test #'equal)))
    #'(lambda (&rest args)
    (multiple-value-bind (val win) (gethash args cache)
      (if win
          val
          (setf (gethash args cache)
            (apply fn args)))))))

;;; With this line I redefine fibs into a memoizing function, as the symbol name isn't changed, it can also call its own memoized version.
(setf (symbol-function 'fibs) (memoize #'fibs))

;;; Let's see how it performs for a large value of n, value that would take unrealistic amounts of time to compute otherwise:
(time (fibs 300))
;Evaluation took:
;  0.000 seconds of real time
;  0.000000 seconds of total run time (0.000000 user, 0.000000 system)
;  100.00% CPU
;  549,234 processor cycles
;  28,480 bytes consed
(fibs 300) ; => 222232244629420445529739893461909967206666939096499764990979600


Not as fancy as Haskell's lazy lists, but being able to turn pure functions into memoizing functions with one command sure is awesome.

Name: Anonymous 2010-12-17 1:37

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2011-02-03 0:32

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