tag:blogger.com,1999:blog-8288194986820249216.post8606811480186188704..comments2024-03-22T05:09:17.789-07:00Comments on Abstract Heresies: 1 minute puzzleJoe Marshallhttp://www.blogger.com/profile/03233353484280456977noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-8288194986820249216.post-49184359838262531062012-03-15T21:02:03.661-07:002012-03-15T21:02:03.661-07:00Third try:
(defun descendants^ (node)
____(append...Third try:<br /><br />(defun descendants^ (node)<br />____(append (children node) (mapcan #'descendants^ (children node))))<br /><br /><a href="http://paste.lisp.org/+2R05/2" rel="nofollow">Highlighted at paste.lisp.org</a>Anonymoushttps://www.blogger.com/profile/12242792031255007733noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-42526364980474960822012-03-13T13:26:28.270-07:002012-03-13T13:26:28.270-07:00Heh, took me longer to figure out how to format th...Heh, took me longer to figure out how to format the comment for blogger.com :-)<br /><br />def descent(node, childrenOf):<br />..for child in childrenOf(node):<br />....yield child<br />....for deep in descent(child, childrenOf):<br />......yield deepUnknownhttps://www.blogger.com/profile/15118033030566743230noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-10365212008291305902012-03-13T09:29:10.987-07:002012-03-13T09:29:10.987-07:00It likely took me a minute to cruft up a simple ca...It likely took me a minute to cruft up a simple car/cdr/cons stack DFS version, but I succumbed to a fit of generalization and result order dinking.<br /><br />http://sprunge.us/PGWV?schemeChristopher Oliverhttps://www.blogger.com/profile/10435352547304680183noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-30392309010579423392012-03-13T06:10:33.036-07:002012-03-13T06:10:33.036-07:00Took me 10 times longer :-)
http://paste.lisp.org...Took me 10 times longer :-)<br /><br />http://paste.lisp.org/display/128318chturnehttps://www.blogger.com/profile/03913967915579154750noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-61027416826748912212012-03-12T20:11:03.150-07:002012-03-12T20:11:03.150-07:00Hmmm, took 24 times longer than the title, but I d...Hmmm, took 24 times longer than the title, but I did it for graphs, not trees I suppose.<br /><br />http://paste.lisp.org/+2R05Anonymoushttps://www.blogger.com/profile/12242792031255007733noreply@blogger.comtag:blogger.com,1999:blog-8288194986820249216.post-4657200840966533522012-03-12T14:57:39.809-07:002012-03-12T14:57:39.809-07:00OK (interpreting 'descendants' as includin...<a href="http://codepad.org/qr0ntRNJ" rel="nofollow">OK</a> (interpreting 'descendants' as including the root).<br /><br />Incorrect solution (descendants = concatMap descendants . children): 20 seconds<br />Unsuccessfully trying to look up the Racket equivalent of concatMap: 5 minutes (it's append-map, but I had to consult SRFI-1 to discover that)<br />Deciding to stick with Haskell: 5 seconds<br />Deciding to actually test it, and finding codepad (via <a href="http://tryhaskell.org/" rel="nofollow">Try Haskell</a>): 1 minute and a painful admission of fallibility<br />Implementation, and fixing the bug: 3 minutes<br />Vacillating between different tree structures: 5 minutes<br />Type errors (recursive type synonym and confusing print with shows): 4 minutes<br /><br />That adds up to one minute, right?Arcane Sentimenthttps://www.blogger.com/profile/04144052171693893368noreply@blogger.com