[plt-scheme] boolean operators on integers

From: Eli Barzilay (eli at barzilay.org)
Date: Sat Jul 12 20:42:49 EDT 2008

On Jul 12, Richard Cleis wrote:
> 
> I occasionally have the need for functions that I never wrote.  They
> would work like string->list, but would instead convert bits of a
> hardware derived number to a list of booleans (rather than
> characters in a string to a list of characters.)  That way, a
> handler could cleanly be applied to the list of boolean values:

Here's a quick hack that works as long as you don't mind the temporary
junk that is generated:

  (map (lambda (x) (eq? x #\1))
       (string->list (number->string 1234 2)))

  (string->number (apply string (map (lambda (x) (if x #\1 #\0))
                                     '(#t #f #f #t #t #f #t #f #f #t #f)))

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.