tag:blogger.com,1999:blog-8513438391157777465.post7411748889217908588..comments2023-04-07T05:56:45.278-07:00Comments on Re: Factor: Maximum/Minimummrjbq7http://www.blogger.com/profile/06842721076008035602noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-8513438391157777465.post-63082594139796558032011-02-07T19:23:20.615-08:002011-02-07T19:23:20.615-08:00@_phred: Nice article!
@paul: I like your decorat...@_phred: Nice article!<br /><br />@paul: I like your decorate/undecorate -- I recognize its a common idiom in languages like Python, too. The main advantage of a sequential approach is that it can operate in O(n) (e.g., linear) time. Often complexity is not a constraint, but sometimes it is.mrjbq7https://www.blogger.com/profile/06842721076008035602noreply@blogger.comtag:blogger.com,1999:blog-8513438391157777465.post-18804346689401188852011-02-05T05:34:01.746-08:002011-02-05T05:34:01.746-08:00An easier approach is the "decorate sort unde...An easier approach is the "decorate sort undecorate" idiom - convert each sequence entry into a { key, value } array, sort that (or use supremum, or whatever) then "undecorate" by extracting the value.<br /><br /><br><br />: decorate ( seq quot: ( key -- val ) -- decorated-seq ) '[ _ keep 2array ] map ; inline<br /><br><br />PEOPLE [ age>> ] decorate supremum second<br /><br><br />For sorting, you can use an "undecorate" word:<br /><br><br />: undecorate ( kv-seq -- seq ) [ second ] map ;<br /><br><br />(Is there any way of formatting code in comments???)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8513438391157777465.post-65131220646094053802011-02-05T01:19:11.073-08:002011-02-05T01:19:11.073-08:00You got me thinking:
http://weblog.fredalger.net/...You got me thinking:<br /><br />http://weblog.fredalger.net/2011/02/sorting-in-factor.html<br /><br />Thinking: always a good thing!Anonymousnoreply@blogger.com