List Comprehension in Swift
duan.ca
List Comprehension in Swift
1–10 of 32 posts
Re: List Comprehension in Swift
#2Ugh, no. I fail to see where the Cartesian product is in::
[(x,y,z) | x
---@dennisvennink
What you feel doesn't matter. It's not a zip.
Re: List Comprehension in Swift
#3This.
Re: List Comprehension in Swift
#4> List comprehension should be no stranger to a Python or (and?) Haskell user. It’s a really compact syntax that deals with Cartesian product [emphasis mine] of lists. Ugh, no. I fail to see where the Cartesian product is in:: [(x,y,z) | x --- @dennisvennink What you feel doesn't matter. It's not a zip.
Re: List Comprehension in Swift
#5> List comprehension should be no stranger to a Python or (and?) Haskell user. It’s a really compact syntax that deals with Cartesian product [emphasis mine] of lists. Ugh, no. I fail to see where the Cartesian product is in:: [(x,y,z) | x --- @dennisvennink What you feel doesn't matter. It's not a zip.
I'm not sure of the original intent, but you could approach this as the Cartesian product of [1..5] * [1..10] * [1..10] which is then filtered such that the 2nd value is not smaller than the first, and the 3rd value is inclusively between the two
Re: List Comprehension in Swift
#6> List comprehension should be no stranger to a Python or (and?) Haskell user. It’s a really compact syntax that deals with Cartesian product [emphasis mine] of lists. Ugh, no. I fail to see where the Cartesian product is in:: [(x,y,z) | x --- @dennisvennink What you feel doesn't matter. It's not a zip.
Re: List Comprehension in Swift
#7Re: List Comprehension in Swift
#8> (Can’t wait until we can have variadic generic parameters!) This.
Re: List Comprehension in Swift
#9Earlier quoted context omitted.
I'm not sure of the original intent, but you could approach this as the Cartesian product of [1..5] * [1..10] * [1..10] which is then filtered such that the 2nd value is not smaller than the first, and the 3rd value is inclusively between the two
A subset of a Cartesian product is not a Cartesian product. inb4, spare me the wisecrack “It's the Cartesian product of itself and no other factors”.
Couldn't taking the subset of a Cartesian product be considered to be dealing with one?
Re: List Comprehension in Swift
#10The Haskell list comprehension made sense to me the first time I saw it, but there is no way I'd know what the mess in the article was doing until someone explained to me.
Design has to come first. You can't just go with what's "Swifty" if that doesn't convey what's happening in a reasonable fashion.