[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: can s-exprs represent a graph without eval?
Guy Steele wrote:
> Sometimes an circular structure can be used to "advantage".
> Consider this bit of code:
> (mapcar #'+ x '#1=(1 -1 . #1#)) [corrected]
> If x is (1 4 7 10), the result will be (2 3 8 9).
> Does this puzzle you? You get 1 point.
> Does this delight you? You get 5 points.
> Does this nauseate you? You get 10 points.
I can see nauseating aspects, but related more to cryptic syntax than
anything else. Should the following Haskell also be considered nauseating,
and if so, why?
x = [1, 4, 7, 10]
altlist = 1 : -1 : altlist
zipWith (+) x altlist
Not sure if the infinite list can be defined inline, but if not, it's
probably a good thing which reduces the nausea factor.
My delight with this version is only moderated by the typing rules, which
require that a different function be used with a different number of input
lists (map vs. zipWith).