[{"data":1,"prerenderedAt":75},["ShallowReactive",2],{"\u002Ftlt-2006.03.03-funky-function-filters":3},{"id":4,"title":5,"body":6,"createdAt":61,"description":62,"draft":63,"extension":64,"image":65,"mastodonThread":65,"meta":66,"navigation":67,"path":68,"seo":69,"stem":70,"tags":71,"updatedAt":73,"__hash__":74},"content\u002FTLT - 2006.03.03 - Funky Function Filters.md","TLT_-_2006.03.03_-_Funky_Function_Filters",{"type":7,"value":8,"toc":58},"minimark",[9,20,23,34,37,43,46,52,55],[10,11,12,19],"p",{},[13,14,18],"a",{"href":15,"rel":16},"http:\u002F\u002Fwww.artima.com\u002Fforums\u002Fflat.jsp?forum=106&thread=150515",[17],"nofollow","Guido van Rossum Re-Posted"," a plea for advertisement of Python. Some of the Python folks are feeling the Ruby squeeze and feel like their leader might be able to make some noise.",[10,21,22],{},"Anyway, in the course of the conversation Guido asked what the Ruby equivalent for this would be:",[24,25,30],"pre",{"className":26,"code":28,"language":29},[27],"language-text","for f in filter(lambda f: f(-1)>=f(1),\n                [lambda x:x, lambda x:x**2, lambda x:x**3]):\n    for x in range(-10, 11):\n        print x, f(x)\n","text",[31,32,28],"code",{"__ignoreMap":33},"",[10,35,36],{},"Which is, of course, a completely useless piece of code demonstrating some lambda functionality. Someone posted the response:",[24,38,41],{"className":39,"code":40,"language":29},[27],"for f in [lambda { |x| x }, lambda { |x| x**2 }, lambda { |x| x**3 }\n         ].select { |f| f.call(-1) >= f.call(1) }\n    for x in -10..10\n        print x, f.call(x)\n    end\nend\n",[31,42,40],{"__ignoreMap":33},[10,44,45],{},"Which is quite similar. I thought I'd give it my hand for Perl5, which looks like this:",[24,47,50],{"className":48,"code":49,"language":29},[27],"for $f (grep {$_->(-1)>=$_->(1)} (\n        (sub{shift},sub{(shift)**2},sub{(shift)**3}) {\n  for $x (-10,10) {\n    print $x,\" \",$f->($x),\"\\n\";\n  }\n}\n",[31,51,49],{"__ignoreMap":33},[10,53,54],{},"Pretty ugly, if I do say so myself. The ugliness comes directly from the lack of a simple named parameter mechanism. The Python and Ruby versions look, like I said, very similar. All three are identical in algorithm... but for once it looks like Perl doesn't do so well on terseness.",[10,56,57],{},"Now I have to figure out what this looks like in Perl6...",{"title":33,"searchDepth":59,"depth":59,"links":60},2,[],"2006-03-03T12:52-05:00","Guido van Rossum Re-Posted a plea for advertisement of Python. Some of the Python folks are feeling the Ruby squeeze and feel like their leader might be able to make some noise.",false,"md",null,{},true,"\u002Ftlt-2006.03.03-funky-function-filters",{"title":5,"description":62},"TLT - 2006.03.03 - Funky Function Filters",[72],"blog","2006-03-03T12:58-05:00","irUXSG1fiTXHgmklOAPTpEcILPi4fSGiFldz1jI1ftk",1778988314005]