Bitwise IO: Difference between revisions

1,296 bytes added ,  13 years ago
Added PicoLisp
(→‎{{header|Perl}}: ++ mips sit)
(Added PicoLisp)
Line 776:
put edit (bs) (b);
</lang>
 
=={{header|PicoLisp}}==
<lang PicoLisp>(de write7bitwise (Lst)
(let (Bits 0 Byte)
(for N Lst
(if (=0 Bits)
(setq Bits 7 Byte (* 2 N))
(wr (| Byte (>> (dec 'Bits) N)))
(setq Byte (>> (- Bits 8) N)) ) )
(unless (=0 Bits)
(wr Byte) ) ) )
 
(de read7bitwise ()
(make
(let (Bits 0 Byte)
(while (rd 1)
(let N @
(link
(if (=0 Bits)
(>> (one Bits) N)
(| Byte (>> (inc 'Bits) N)) ) )
(setq Byte (& 127 (>> (- Bits 7) N))) ) )
(when (= 7 Bits)
(link Byte) ) ) ) )</lang>
<lang PicoLisp>(out 'a (write7bitwise (127 0 127 0 127 0 127 0 127)))
(hd 'a)
(in 'a (println (read7bitwise)))
 
(out 'a (write7bitwise (0 127 0 127 0 127 0 127 0)))
(hd 'a)
(in 'a (println (read7bitwise)))
 
(out 'a (write7bitwise (mapcar char (chop "STRING"))))
(hd 'a)
(println (mapcar char (in 'a (read7bitwise))))</lang>
Output:
<pre>00000000 FE 03 F8 0F E0 3F 80 FE .....?..
(127 0 127 0 127 0 127 0)
00000000 01 FC 07 F0 1F C0 7F 00 .......
(0 127 0 127 0 127 0 127)
00000000 A7 52 94 99 D1 C0 .R....
("S" "T" "R" "I" "N" "G")</pre>
 
=={{header|Python}}==
Anonymous user