RosettaCodeData/Task/Bitmap-Read-a-PPM-file/PicoLisp/bitmap-read-a-ppm-file-1.l
Ingy döt Net 518da4a923 B
2013-04-10 16:19:29 -07:00

18 lines
655 B
Text

(de ppmRead (File)
(in File
(unless (and `(hex "5036") (rd 2)) # P6
(quit "Wrong file format" File) )
(rd 1)
(let (DX 0 DY 0 Max 0 C)
(while (>= 9 (setq C (- (rd 1) `(char "0"))) 0)
(setq DX (+ (* 10 DX) C)) )
(while (>= 9 (setq C (- (rd 1) `(char "0"))) 0)
(setq DY (+ (* 10 DY) C)) )
(while (>= 9 (setq C (- (rd 1) `(char "0"))) 0)
(setq Max (+ (* 10 Max) C)) )
(prog1
(make (do DY (link (need DX))))
(for Y @
(map
'((X) (set X (list (rd 1) (rd 1) (rd 1))))
Y ) ) ) ) ) )