Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

amahabal (8575)

amahabal
  (email not shown publicly)
+ -

  Comment: ... but note that principia itself is not (Score 1) on 2009.05.12 16:58

by amahabal on 2009.05.12 16:58 (#68544)
Attached to: Optimizing for wetware
Comments: 2
+ -

  Comment: Re:but just one thing more (Score 1) on 2009.03.03 23:12

by amahabal on 2009.03.03 23:12 (#67682)
Attached to: RPN Take 4
I was hoping to use zero arity like so:

'pi' => { 3.1415926 }

Perhaps

'sum' => { @stack = [+]@stack; } but WholeStack,

or something along those lines would work.

Read More 3 comments
Comments: 3
+ -

  Comment: Re:Making it even more compact... (Score 1) on 2009.03.03 13:58

by amahabal on 2009.03.03 13:58 (#67677)
Attached to: a(nother) Reverse Polish Notation Calculator
I have one version here: http://use.perl.org/~amahabal/journal/38583 Thanks to your suggestion, I added 'say' and 'rotate3'. I will try my original idea next, for which I need to go from a name (such as 'double') to a callable object (&double). Not sure yet what I'd do with multis and such, but I will see how far I get.
Read More 4 comments
Comments: 4
+ -

  Journal: RPN Take 4 on 2009.03.03 13:52

Journal by amahabal on 2009.03.03 13:52
User Journal
fREW++ and pmichaud++ have, between them, three versions of the RPN calculator. Here is a fourth, clener in some ways. You can use it as follows:

./perl6 rpn.pl '4 5 9 sqrt + *'
32
> ./perl6 rpn.pl '4 5 9 sqrt rotate3 + *'
35

And here is the code:

Read More 3 comments
Comments: 3
+ -

  Comment: Making it even more compact... (Score 1) on 2009.03.02 23:14

by amahabal on 2009.03.02 23:14 (#67670)
Attached to: a(nother) Reverse Polish Notation Calculator
I don't know how to do this, but I am sure Patrick or Jonathan can do this quickly... In the code above, there is still repetition: all entries in %op_dispatch_table are nearly identical, differing only depending on the arity. We could replace that with something generic which is passed a sub, it pops as many elements as the arity of the passed sub and pushes back the value of applying the sub to the reverse of this list. I was unable to do this myself because I could not get from the name of the sub to the callable object (I tried &($name), but got a message that it is unimplemented).
Read More 4 comments
Comments: 4