o icon indicating copy to clipboard operation
o copied to clipboard

CodeBlock Arithmetic

Open phase opened this issue 8 years ago • 16 comments

  • {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, printing 234. (No idea how to implement this :fearful:)

Thoughts @kirbyfan64?

phase avatar Nov 21 '15 23:11 phase

@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

refi64 avatar Nov 21 '15 23:11 refi64

@kirbyfan64 Oh yeah, forgot about that operator :panda_face:. I don't know what else it could be.

phase avatar Nov 21 '15 23:11 phase

What if * is map and / is instead a "fold", like / in K?

refi64 avatar Nov 22 '15 19:11 refi64

That makes sense, though using arithmetic operators on arrays already folds them.

phase avatar Nov 22 '15 21:11 phase

@phase Well, / could be for arbitrary code blocks, not just arithmetic operations.

refi64 avatar Nov 22 '15 22:11 refi64

So something like [421] {+3-}/ > 4+(2+(1-3)-3)-3?

phase avatar Nov 22 '15 22:11 phase

@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.

refi64 avatar Nov 22 '15 23:11 refi64

We can just use whatever way [123]+ folds.

phase avatar Nov 22 '15 23:11 phase

@phase That would be a left fold!

refi64 avatar Nov 22 '15 23:11 refi64

% 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 avatar Nov 24 '15 05:11 phase

@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.

refi64 avatar Nov 27 '15 22:11 refi64

@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]

phase avatar Nov 28 '15 06:11 phase

Damn it, wrong issue. :/

refi64 avatar Jun 20 '16 00:06 refi64

@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...

refi64 avatar Jun 20 '16 00:06 refi64

What use cases does only removing adjacent duplicates have?

phase avatar Jun 20 '16 04:06 phase

@phase ...I honestly have no clue. I was just thinking of how uniq works. :O

refi64 avatar Jun 26 '16 20:06 refi64