Berkeley CSUA MOTD:Entry 13416
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2025/05/25 [General] UID:1000 Activity:popular
5/25    

2004/4/27 [Academia/Berkeley/Classes] UID:13416 Activity:nil
4/27    I forgot if I posted this before or not, but here's another fun
        problem:  Write the factorial function in any language of your
        choice without using any iterative constructs or named functions.
          -- ilyas
          \_ Here's another fun problem: Write your next major project without
             using user defined functions or subroutines utilizing only goto
             commands. After you have completed that task try climbing the
             stairs of your favorite building while hopping only on one foot.
             --williamc
             \_ Why lift weights?  It's such an artificial problem!  Almost
                no one actually needs to move weights around.  Just lift
                your arms instead.  Why prove stuff only using ZFC axioms?
                Just add whatever axioms you need, why restrict yourself to
                so little? -- ilyas
                \_ the only reasonable reason to do any of those is for
                   fun.  lifting weights is stupid.
                   \_ Either for fun or to develop a skill, or for reasons
                      of maintainability (that's the example of proving using
                      as little as possible).  At any rate, I am of the opinion
                      that folks that look down on these sorts of problems
                      as 'useless in the real world' have a dangerous case
                      of blinders coupled with an incurable case of vanity.
                      Certainly, nothing appearing in SICP is stupid.
                        -- ilyas
                \_ don't mind williamc. he's generally proved himself to be
                   kind of a dumbass anyway. in any case, perhaps ken thompson
                   put it best:
                   "In college, before video games, we would amuse ourselves
                    by posing programming exercises. One of the favorites was
                    to write the shortest self-reproducing program. Since this
                    is an exercise divorced from reality, the usual vehicle was
                    FORTRAN. Actually, FORTRAN was the language of choice for
                    the same reason that three-legged races are popular."
                    \_ three-legged races are popular?  -tom
                       \_ do we forget our childhoods so quickly?
                    \_ Many many years ago, after I told my dad that I taught
                       myself how to program, he gave me that problem.  I did
                       it (in Pascal), but it turned out that he expected me to
                       read the program file from disk and print it out!
                       \_ WOW, YOU'RE SMRT!!!
          \_ Or trying going one more day without pissing in your boss's
             coffee mug.  This one is much harder than the above but it *can*
             be done!
        \_ you already asked this, and anyone who's taken CS61A has seen it as
           the extra-for-experts problem to assignment 1 (or was it 2?)
        \_ float factorial(int i) {
             const float f[] = {1, 1, 2, 6, 24, 120, ... and so on ... };
             return f[i];
           }
           \_ of course, this doesn't work for arbitrary n, and "factorial" is
              a named function.
              \_ Then how do you write a C function without a name?  And which
                 language would let you write the said function while
                 supporting arbitary n anyway?
                 \_ And finally we come to the purpose of this question...
                 \_ Take CS61A sometime.
                    \_ CS61A tells me the former or the latter?
                       \_ well, since C doesn't support anonymous functions,
                          and since 61A doesn't cover C: the latter.
        \_ Sterling's formula?
           \_ Exact answers only please.  I respect your good attempt though.
                -- ilyas
        \_ ; replace ___ with the value you want factorialed
           ((lambda (f n) (if (<= n 1) 1 (* n (f f (- n 1)))))
            (lambda (f n) (if (<= n 1) 1 (* n (f f (- n 1)))))
            ___)
            \_ Nicely done.  The keyword for this sort of trickery is
               'continuation passing style.' -- ilyas
2025/05/25 [General] UID:1000 Activity:popular
5/25    

You may also be interested in these entries...
2004/2/19 [Academia/Berkeley/Classes] UID:29822 Activity:low
2/19    Any students here would like to comment on EECS enrollment after
        the dot-com collapse?  How many people enrolled in CS61A?  When I
        was a freshman there were only about 100 some odd people in 60A.
        I heard it ballooned to 400+ at the height of the boom.  What happened
        after that?
        \_ you realize that most people who post on motd are NOT enrolled
	...
2003/7/15-16 [Academia/Berkeley/Classes] UID:29037 Activity:low
7/14    When I was in CS61A there was a program that would let you view
        your scheme code as a flowchart. Does anyone remember the
        name of the program?
        \_ When I was your age, cs61a was called cs60a and we used real
           editors (emacs without hilit mode) and real workstations like
           the Apollos and later on the really awsome DEC3000s.
	...
2003/5/11-12 [Academia/Berkeley/Classes, Academia/UCLA] UID:28409 Activity:high
5/11    I have been accepted to UCLA for Fall 03 (CS & Engr) and to Berkeley
        for Spring 04 (EECS), granted that I take a community college class
        in Fall. Is Berkeley worth waiting for and why?
        \_ yes.
        \_ Are you posting for someone or is this for grad school?  If the
           latter it's all about your advisor.
	...
2001/11/24-27 [Academia/Berkeley/Classes, Computer/Theory] UID:23094 Activity:insanely high
11/23   Can someone please tell me what textbook and/or author we used for:
        math50a, math55, and stat134? I need it from 1993-1995. THANKS!
        \_ let me guess, ypu're applying to MIT, right?
           \_ let me guess, you're also applying to MIT, right? Or are you
              already there? Help me out dude...
              \_ I'm applying. And I'm a dudette, btw. -chialea
	...
2001/10/21 [Academia/Berkeley/Classes] UID:22788 Activity:high
10/21   You are required to know recursion before taking CS 61a?  Where
        would they learn it aside from CS 3?  AP CS?
        \_ I didn't know what recursion was my freshman year when I took
           61a. It took me all but 5 minutes to look it up in SICP and I
           passed the test. Never took CS 3 or AP CS.
           \_ Damn, you're cool!
	...
2001/10/10-11 [Academia/Berkeley/Classes] UID:22685 Activity:high
10/11   officially, enrollment in cs61a DOWN 100 from last sem.
        \_ must be the recession, what those freshmen dont know is that by
           the time they graduate, we should(I hope) be ready for the next
           boom
           \_ The next boom won't be CS. Maybe some bio stuff.
        \_ GOOD. You should study computer science because you love it,
	...
2000/5/30-6/1 [Academia/Berkeley/Classes] UID:18365 Activity:moderate
5/30    Anybody have an example of how to use emacs in batch mode?  I have
        a bunch of files I want worked on inside emacs and I want to do so
        in a non-interactive fashion.  Thanks.
        \_ emacs --batch --load program.el
           \_ Err...  I know how to invoke it, I'm looking for an example of
              "program.el".  Thanks.
	...