[plt-scheme] how read list
> i have text
> "{"Dialogs",
> {"Frame",
[text cut]
>
> how i can fast read it as list?
> How escape "," on reader?
> Replace to whitespace - not optimal, because text may be very long (more
> than 2M)
Just to mention: you could also just read in the structure, commas and
all, and then flatten out all the superfluous structure afterwards.
Here's some code to show what I mean:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(module flatten-bananas mzscheme
(require (lib "plt-match.ss"))
(provide flatten-bananas)
;; Remove bananas from our datum.
(define (flatten-bananas datum)
(match datum
((list 'banana subdatum)
(flatten-bananas subdatum))
((list elts ...)
(map flatten-bananas elts))
(else
datum))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
For example:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (flatten-bananas '((banana
(banana
(monana
(banana
ana))))))
((monana ana))
> (flatten-bananas '(ingredients (banana cream)
(banana milk)
(banana strawberry)))
(ingredients cream milk strawberry)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Hmm... getting hungry. In any case, hope this helps!