o
o copied to clipboard
CodeBlock Arithmetic
-
{1o}3*
should run the block 3 times. -
[123]{)o}/
Should run the block for every object in the array with the object placed on the top of the stack, printing234
. (No idea how to implement this :fearful:)
Thoughts @kirbyfan64?
@phase I think I know how to implement the second one, but isn't the first basically the same thing as d
? 3{1o}d
@kirbyfan64 Oh yeah, forgot about that operator :panda_face:. I don't know what else it could be.
What if *
is map and /
is instead a "fold", like /
in K?
That makes sense, though using arithmetic operators on arrays already folds them.
@phase Well, /
could be for arbitrary code blocks, not just arithmetic operations.
So something like [421] {+3-}/
> 4+(2+(1-3)-3)-3
?
@phase Either that (a right fold) or a left fold: (((1+2)-3)+4)-3
. Which would you prefer? I believe Pyth and K do a left fold.
We can just use whatever way [123]+
folds.
@phase That would be a left fold!
%
can be a filter, like [0101] {n>0} %
. It would pop the stack after it runs each CB and if truthy, push that element to a separate array. I've got an idea on how to implement it.
@phase I'm sorry this (and #50) have been so delayed. I've been trying to do a lot of stuff at once, and it doesn't always end too well.
@kirbyfan64 No problemo :heart: :palm_tree:
I had an idea about unique filtering, as that seems to be the craze.
[11223344]!%o
[1, 2, 3, 4]
or maybe use `|`, which is our last free symbol
[56565563]|o
[5, 6, 3]
or `u` for `unique`
[2345672345678]uo
[2, 3, 4, 5, 6, 7, 8]
Damn it, wrong issue. :/
@phase What if the unique sort only removed adjacent duplicates? Since sort is now implemented (#48), for full duplicate removal, one could do [xyz]s!%
, e.g. just sort the items first.
Also, my vote goes to !%
, since we're don't necessarily have a significant number of one-character functions left...
What use cases does only removing adjacent duplicates have?
@phase ...I honestly have no clue. I was just thinking of how uniq
works. :O