tag:blogger.com,1999:blog-7094652.post3806981827422662779..comments2019-05-21T16:48:42.567+01:00Comments on Neil Mitchell's Haskell Blog: Pascal's Triangle in HaskellNeil Mitchellhttp://www.blogger.com/profile/13084722756124486154noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-7094652.post-61051418838364033192012-01-09T14:18:16.403+00:002012-01-09T14:18:16.403+00:00Interesting question! :-)
Here's a silly solu...Interesting question! :-)<br /><br />Here's a silly solution I came up with:<br /><br />> pascals = [1] : map (zipWith (+) <$> ([0] ++) <*> (++ [0])) pascalsNicolas Wuhttps://www.blogger.com/profile/02348304911037199052noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-24805676038600545682012-01-09T04:19:24.303+00:002012-01-09T04:19:24.303+00:00Yes, in my experience interviewers will grimace at...Yes, in my experience interviewers will grimace at you if you solve their whiteboard problem in concise mathematical Haskell.<br /><br />Even the rare interviewer that would be delighted if you did it in Common Lisp.Fred Blasdelhttps://www.blogger.com/profile/08057528812732998703noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-41222459124665913432012-01-08T21:51:56.048+00:002012-01-08T21:51:56.048+00:00> I wonder if using Haskell in a job interview ...> I wonder if using Haskell in a job interview should be considered cheating? ;-)<br />I wouldn't consider using the right tool for the right job cheating.<br /><br />After all, Haskell is pretty much literal Mathematics. And the Pascal Triangle is a Mathematical definition.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7094652.post-25406994340664930672012-01-08T16:53:39.438+00:002012-01-08T16:53:39.438+00:00It is not as elegant as in Haskell, but you can do...It is not as elegant as in Haskell, but you can do something similar in Python using generators.<br /><br />http://pastebin.com/1CjqH174Jan Van lentnoreply@blogger.comtag:blogger.com,1999:blog-7094652.post-28531541303970441852012-01-08T14:35:10.957+00:002012-01-08T14:35:10.957+00:00Anon: I did wonder if I should do that version mys...Anon: I did wonder if I should do that version myself - since what I've really done is a peephole optimisation of that where you know head xs == last xs == 1. Thinking further, you are completely right, so I've switched to your version. For future reference, my original version was:<br /><br />next xs = [1] ++ zipWith (+) xs (tail xs) ++ [1]Neil Mitchellhttps://www.blogger.com/profile/13084722756124486154noreply@blogger.comtag:blogger.com,1999:blog-7094652.post-15106371872799681292012-01-08T13:45:27.842+00:002012-01-08T13:45:27.842+00:00Ok, it's a bit silly to quibble like this, but...Ok, it's a bit silly to quibble like this, but I can't resist:<br /><br />What about<br /><br />next xs = zipWith (+) ([0] ++ xs) (xs ++ [0])<br /><br />?Anonymousnoreply@blogger.com