
In a response to me on the "powerset" thread, you wrote: At 19:50 04/06/03 -0400, Derek Elkins wrote:
In fact, you could rewrite the whole thing as concatMap (flip combinations as) [1..length as]. A list comprehension with only one source and no filters is the same as a map.
Is there any particular reason to avoid using a list comprehension, even if
a map would do? I ask because I seem not infrequently to find that a list
comprehension is more compact and easier to read, even though map could
suffice. This may be when the applied function is relatively complex, and
would otherwise require a sequence of 'where' definitions.
My current example is this:
[[
-- |Graph substitution function.
-- This function performs the substitutions in 'vars', and
-- replaces any nodes corresponding to unbound query variables
-- with new blank nodes.
rdfQuerySubsBlank :: RDFQueryBindings -> RDFGraph -> [RDFGraph]
rdfQuerySubsBlank vars gr =
[ remapLabels vs bs True g
| v <- vars
, let (g,vs) = rdfQuerySubs2 v gr
, let bs = allLabels isBlank g
]
]]
I could write it with map, but the ways I came up with all seemed
convoluted and difficult to follow.
#g
-------------------
Graham Klyne