[plt-scheme] How do I do this in true functional style?
Doug Orleans <dougo at place.org> writes:
> Joe Marshall writes:
> > Additionally, you may wish to use the printed representation of the
> > desired 3-dimensional array of booleans. This will avoid the entire
> > process of initialization.
>
> What if the array is very sparse, e.g. a 100x100x100 cube with 20
> points?
It depends. If most of the arrays at runtime are like this, then it
might be better to use a sparse representation everywhere.
> > I use Emacs macros, SED, AWK, LEX, or whatever to strip out noise
> > like commas and put in parenthesis, quotations, etc.
>
> Dumb question, but why not use Scheme to do this?
Mostly because it's somewhat of a pain in Scheme. Many of those
random curly-brace variant syntaxes out there were designed with
LEX/YACC in mind, and often come packaged with the LEX/YACC grammar.
Translating from this into Scheme is time consuming and error prone,
and the resulting Scheme code is generally much slower.
Or I might be browsing some random text file in Emacs when I
realize I want to read it into Scheme. The time it takes to use
`query-replace-regexp' or type a keyboard macro is miniscule compared
to the time to actually write a parser in Scheme.