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;22001-08-10 10:27:02
          ARRRGH! Double faulting again! by Schol-R-LEA;2 2001-08-10 11:32:55
I screwed up the code in the last posting, so now I have to reply to a reply to my own post - of two weeks back.
The code should be more like:
(define (infix x) (eval (append (list (cadr x) (car x)) (cddr x))))
I actually tested this one (under Guile), and it works right, even if it is a bit long for a one-liner. a cleaner, but longer, version would be:
(define (infix x) 
   (let* ((op    (cadr x))
         (term1  (car  x))
         (term2  (cddr x))
         (operation (append (list op term1) term2))) 
      (eval operation)))
Also, the other example I gave should have been: (infix '('a cons 'b)) ==> (a . b) It still doesn't have any error checking, though, and I'm just too lazy to bother right now.
[ Reply ]

 

[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.)