|
I've got this code:code:
I'm not sure why the for comprehension isn't actually yielding what I think it should be yielding. Any suggestions for what to look at? What am I missing?
|
# ¿ Aug 2, 2016 15:39 |
|
|
# ¿ May 11, 2024 13:05 |
|
mutantmell posted:It's hard to tell what exactly is going on here without knowing what b, d, a, and fun are. Well, that's why I included the types for those in the code sample. The first two elements all produce something when tried independently, so there's something off in the recursion, but I'm not sure where the flat List() is coming from--I'd expect to see List(List()) if there was no data. Debugging in the scala ide isn't helping, either.
|
# ¿ Aug 2, 2016 22:09 |
|
mutantmell posted:If any of the lists on the right of the '<-' is empty, then the result will be 'List()'. The for-comprehension can be read as "for each element foo in b, for each element bar in d(a), for each element baz in fun(q - foo), transform it into bar :: baz)'. If any of those lists are empty, then it cannot do anything. Thanks! I'll try this out today.
|
# ¿ Aug 3, 2016 13:53 |
|
KernelSlanders posted:Is baz a List[String] or is fun(q - foo) a List[String]? Turned out the method I was using to calculate (q - foo) was the culprit--fixing that resolved everything else.
|
# ¿ Aug 12, 2016 01:07 |