Paste number 29644: hexadecimal string to nested binary string list

Index of paste annotations: 1

Paste number 29644: hexadecimal string to nested binary string list
Pasted by: anaran
When:5 years, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+MVG
Channel:#xemacs
Paste contents:
Raw Source | XML | Display As
(mapcar
 (lambda (c)
   (let ((number (string-to-number (char-to-string c) 16))
         result)
     (dotimes (bit 4 result)
       (if (> (logand (expt 2 bit) number) 0)
           (push "1" result)
         (push "0" result)))))
 "d41d8cd98f00b204e9800998ecf8427e")
->
(("1" "1" "0" "1")
 ("0" "1" "0" "0")
 ("0" "0" "0" "1")
 ("1" "1" "0" "1")
 ("1" "0" "0" "0")
 ("1" "1" "0" "0")
 ("1" "1" "0" "1")
 ("1" "0" "0" "1")
 ("1" "0" "0" "0")
 ("1" "1" "1" "1")
 ("0" "0" "0" "0")
 ("0" "0" "0" "0")
 ("1" "0" "1" "1")
 ("0" "0" "1" "0")
 ("0" "0" "0" "0")
 ("0" "1" "0" "0")
 ("1" "1" "1" "0")
 ("1" "0" "0" "1")
 ("1" "0" "0" "0")
 ("0" "0" "0" "0")
 ("0" "0" "0" "0")
 ("1" "0" "0" "1")
 ("1" "0" "0" "1")
 ("1" "0" "0" "0")
 ("1" "1" "1" "0")
 ("1" "1" "0" "0")
 ("1" "1" "1" "1")
 ("1" "0" "0" "0")
 ("0" "1" "0" "0")
 ("0" "0" "1" "0")
 ("0" "1" "1" "1")
 ("1" "1" "1" "0"))

Annotations for this paste:

Annotation number 1: String hack
Pasted by: sachac
When:5 years, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+MVG/1
Paste contents:
Raw Source | Display As
(let ((hex-string "d41d8cd98f00b204e9800998ecf8427e"))
  (mapconcat
   (lambda (x)
     (nth (string-to-number x 16)
          '("0000" "0001" "0010" "0011"
            "0100" "0101" "0110" "0111"
            "1000" "1001" "1010" "1011"
            "1100" "1101" "1110" "1111")))
   (split-string hex-string "" t) ""))

Colorize as:
Show Line Numbers
Index of paste annotations: 1

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.