Menu

#64 Do an implicit , for :

0.6.5
open
aditsu
None
2015-05-14
2015-05-13
Optimizer
No

We already do an implicit , for various operators and features. For example 5{}% is equivalent to 5,{}%

I think this can be easily extended to : without any issues or arity clashes.

This means that 5:+ will return 10 and likewise

Discussion

  • Optimizer

    Optimizer - 2015-05-13

    The same goes for the .X operator. If any of the two operands is a number (or heck if both are numbers), then do an implicit ,

    This way, we can do quite a few things in a shorter manner. Get an array of first N squares ? :

    N_.*

    Instead of the usual

    N,2f#

    or

    N{_*}%

     
  • Martin Büttner

    Martin Büttner - 2015-05-13

    Can I add f to the list? Like 5Xf+ gives [1 2 3 4 5].

     
  • Optimizer

    Optimizer - 2015-05-13

    I initially thought that. But f's both arguments can be anything and the behavior changes with which one is which. So can you not say that doing 5Xf+ means doing [0 1 2 3 4][0]f+ which gives [[0 0] [1 0] [2 0] [3 0] [4 0]] ?

    What is the differentiating factor here ?

     
  • Dennis

    Dennis - 2015-05-14

    f expects the leftmost argument to be iterable and only iterates over the right one if the left one isn't. Implementing Long Long f as Martin suggests is consistent with that.

     
    • Optimizer

      Optimizer - 2015-05-15

      <ignore this="">

       

      Last edit: Optimizer 2015-05-15
  • Martin Büttner

    Martin Büttner - 2015-05-14

    Yeah I meant what Dennis said. If it's Long Long f you turn the first one into a range. One could also implement Character Long f, by either turning the character into a string, or the long into a range. I think the latter would be more consistent and likely more useful, since none of the block operators currently turn characters into strings I think.

     
    • Optimizer

      Optimizer - 2015-05-15
       

      Last edit: Optimizer 2015-05-15

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.