Re: [Factor-talk] How would I solve this better in Factor?
Wow, your words are simple and fit in single lines. Do you write pseudo code that is more expressible in factor or do you write traditional imperative style pseudo code and then translate them to a factor representation? Thanks, Sankar On 2/25/16 12:01 PM, Jon Harper wrote: > "Hi, > I wrote a basic o(n^4) solution to see how simple it could get. The > code looks nice to me, but it's sllw :) like 1 hour on the 3200 > chars string.. http://paste.factorcode.org/paste?id=3843 > > I noticed we have 1 function in common : remove-after-underscore. You > can can see how head and when* make my implementation shorter (and > more readable?) > > Cheers, > Jon > > > On Wed, Feb 24, 2016 at 5:50 AM, Sankaranarayanan Viswanathan >wrote: >> Hi, >> >> It had been awhile since I wrote any Factor code, so I was trying to >> solve the following problem from reddit's dailyprogrammer subreddit: >> http://bit.ly/1OtP8Qj >> >> The solution I came up with in Factor looks like this: >> http://bit.ly/1PY8j98 >> >> I struggled quite a lot coming up with this. Mainly in keeping things in >> my head and figuring out what I needed to do to bring the stack in order >> for the operations I was attempting.. >> >> Coming from an iterative programming background (with a little bit of >> exposure to functional programming), I find it quite hard to formulate >> solutions in Factor. Can someone help me with tips on how they approach >> writing code in Factor? What is your though process to turn a given >> pseudo code into a factor program? >> >> For example, my pseudo code for the main portion of this problem (the >> find-match function) was as follows: >> >> let buff = "" >> let match = (indx=0, length=-1) >> for each char c in input: >> find count(c) in buff >> if count == 2 >> append c to buff >> check if str(first c to end) is longest and update match >> remove chars in buff before second c occurrence >> else if count == 1 >> append c to buff >> check if str(first c to end) is longest and update match >> remove chars in buff before first c occurrence >> else >> append c to buff >> discard buff and return match >> >> Any pointers is greatly appreciated. >> >> Thanks, >> Sankar >> >> >> -- >> Site24x7 APM Insight: Get Deep Visibility into Application Performance >> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >> Monitor end-to-end web transactions and take corrective actions now >> Troubleshoot faster and improve end-user experience. Signup Now! >> http://pubads.g.doubleclick.net/gampad/clk?id=272487151=/4140 >> ___ >> Factor-talk mailing list >> Factor-talk@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/factor-talk > > -- > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151=/4140 > -- Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=272487151=/4140 ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] benchmark comparing Factor to ANS-Forth
Hi Hugh, Are you planning on implementing your program in Factor for comparison? You can look over our statistics libraries here: http://docs.factorcode.org/content/vocab-math.statistics.html Best, John. On Fri, Feb 26, 2016 at 2:47 PM, Hugh Aguilarwrote: > My first-ever ANS-Forth program was LowDraw.4th that was written about > 12-15 years ago. It is now one of my example programs in the novice > package: http://www.forth.org/novice.html This program does a > recursive-traversal of all the possible hands in LowDraw poker given > various drawing strategies and calculates the probabilities. > > The subject of bench-marking has been discussed a few times on > comp.lang.forth and I have suggested that my program would make a good > benchmark. Most benchmarks involve doing the same simple calculation > repeatedly inside of a loop and/or testing what code-library functions are > available, which provides almost no information about the language speed. > My program is non-trivial at the level of a real-world program, but is yet > simple enough that most programmers should be able to implement it in their > favorite language over a weekend (note: today is Friday). > > I think that Factor has a good chance of beating SwiftForth, but is > unlikely to come close to VFX (there are free evaluation versions of both > available for download). I would be interested in seeing how Factor > compares. I would also be interested in seeing how Oforth compares (is > Oforth discussed on this forum at all?). > > I'm learning R right now, and intend to port my program over to R to > benchmark R's speed (I'm not expecting R to be very fast). The advantage of > R seems to be a lot of code-libraries for statistics, and convenient > representation of arrays of numbers. Factor's sequences should be equally > convenient --- how does Factor compare in regard to code-libraries for > statistics? --- I'm trying to learn statistics these days, which is a > subject I have always wanted to know more about. > > I still have my STUNDURD.TXT design of a micro-controller that supports > quotations at the machine-language level --- right now you have to have me > email it to you if you are interested, because thewww.forth.org website > is stuck (the guy who maintains it had a stroke) --- afaik, Stundurd Forth > is an appropriate topic for this forum, as is any Forth-derived language > that supports quotations. > > regards --- Hugh > > > > -- > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151=/4140 > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk > > -- Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=272487151=/4140___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
[Factor-talk] benchmark comparing Factor to ANS-Forth
My first-ever ANS-Forth program was LowDraw.4th that was written about 12-15 years ago. It is now one of my example programs in the novice package: http://www.forth.org/novice.html This program does a recursive-traversal of all the possible hands in LowDraw poker given various drawing strategies and calculates the probabilities. The subject of bench-marking has been discussed a few times on comp.lang.forth and I have suggested that my program would make a good benchmark. Most benchmarks involve doing the same simple calculation repeatedly inside of a loop and/or testing what code-library functions are available, which provides almost no information about the language speed. My program is non-trivial at the level of a real-world program, but is yet simple enough that most programmers should be able to implement it in their favorite language over a weekend (note: today is Friday). I think that Factor has a good chance of beating SwiftForth, but is unlikely to come close to VFX (there are free evaluation versions of both available for download). I would be interested in seeing how Factor compares. I would also be interested in seeing how Oforth compares (is Oforth discussed on this forum at all?). I'm learning R right now, and intend to port my program over to R to benchmark R's speed (I'm not expecting R to be very fast). The advantage of R seems to be a lot of code-libraries for statistics, and convenient representation of arrays of numbers. Factor's sequences should be equally convenient --- how does Factor compare in regard to code-libraries for statistics? --- I'm trying to learn statistics these days, which is a subject I have always wanted to know more about. I still have my STUNDURD.TXT design of a micro-controller that supports quotations at the machine-language level --- right now you have to have me email it to you if you are interested, because thewww.forth.org website is stuck (the guy who maintains it had a stroke) --- afaik, Stundurd Forth is an appropriate topic for this forum, as is any Forth-derived language that supports quotations. regards --- Hugh -- Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=272487151=/4140___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk