Talk:Dot product: Difference between revisions
m
no edit summary
(zipWidth and 'functional') |
mNo edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 65:
:And, thanks! --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 19:36, 27 February 2016 (UTC)
:: Thanks – that seems sensible – On zip and
::<lang Haskell>zipWith :: (a->b->c) -> [a]->[b]->[c]
zipWith _f [] _bs = []
Line 71:
zipWith f (a:as) (b:bs) = f a b : zipWith f as bs</lang>
:: On the incumbent function, my reservation is not so much about the properties of the code per se as the characterisation of it as 'functional', when it would actually break functional composition. Perhaps just leave it as a variant, without the jokey dedication ? [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 21:18, 27 February 2016 (UTC)
::: Hmm.... from my point of view, "robust" in the context of "programmer interaction" means: "easily describable" and "useful". But you also want to bubble problems up to the programmer. And, in my experience, "mis-matched lengths" is almost always a problem. If the programmer really wanted the shortest of the two, it's easy enough to discard the unwanted elements from the longer list.
::: Not sure about the larger issue, though -- I can see both sides of this and haven't made up my mind. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 21:25, 27 February 2016 (UTC)
::::Not sure how that looks – I've adjusted zipWith to return undefined when array lengths vary (it certainly does simplify the top level of dotProduct), and for the moment I've left the earlier code in place, and just reframed its characterisation. [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 22:08, 27 February 2016 (UTC)
::::(and, just now, swapping in your zipWith - which is much cleaner and more pleasing)[[User:Hout|Hout]] ([[User talk:Hout|talk]]) 00:41, 28 February 2016 (UTC)
:::::This looks good. Thanks. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 01:47, 28 February 2016 (UTC)
|