The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Yet another programming question by Schol-R-LEA;22001-07-31 03:21:51
  Tertiary Operators!!! by beez2001-07-31 17:39:18
    These are fun! by BoisePaul2001-07-31 19:19:23
      That's easy (warning, spoilers) by Schol-R-LEA;22001-07-31 20:12:07
        I forgot to mention that by Schol-R-LEA;2 2001-08-10 10:27:02
You can do the whole program in Scheme as a one-liner with no conditional at all:

(define (infix x) (eval ((cdar x) (car x) (cddr x)))

Where x is assumed to be a list like

'(1 + 2)

so that

(infix '(3 * 4))
==> 12

The ability to evaluate data as code (and vis versa) is a Good Thing. BTW, this works with any valid Scheme function with an arity of 2:

(infix '(a cons b))
==> (a b)

Of course, there's no error checking in case the arguments are bogus, but there wasn't any in the other version either, so...
[ Reply ]
          ARRRGH! Double faulting again! by Schol-R-LEA;22001-08-10 11:32:55

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)