Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeBlock Arithmetic #49

Open
phase opened this issue Nov 21, 2015 · 16 comments
Open

CodeBlock Arithmetic #49

phase opened this issue Nov 21, 2015 · 16 comments

Comments

@phase
Copy link
Owner

phase commented Nov 21, 2015

  • {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 馃槰)

Thoughts @kirbyfan64?

@refi64
Copy link
Collaborator

refi64 commented Nov 21, 2015

@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

@phase
Copy link
Owner Author

phase commented Nov 21, 2015

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

@refi64
Copy link
Collaborator

refi64 commented Nov 22, 2015

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

@phase
Copy link
Owner Author

phase commented Nov 22, 2015

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

@refi64
Copy link
Collaborator

refi64 commented Nov 22, 2015

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

@phase
Copy link
Owner Author

phase commented Nov 22, 2015

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

@refi64
Copy link
Collaborator

refi64 commented Nov 22, 2015

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

@phase
Copy link
Owner Author

phase commented Nov 22, 2015

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

@refi64
Copy link
Collaborator

refi64 commented Nov 22, 2015

@phase That would be a left fold!

@phase
Copy link
Owner Author

phase commented Nov 24, 2015

% 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 added a commit that referenced this issue Nov 24, 2015
phase added a commit that referenced this issue Nov 24, 2015
@refi64
Copy link
Collaborator

refi64 commented Nov 27, 2015

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

@phase
Copy link
Owner Author

phase commented Nov 28, 2015

@kirbyfan64 No problemo 鉂わ笍 馃尨

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]

@refi64
Copy link
Collaborator

refi64 commented Jun 20, 2016

Damn it, wrong issue. :/

@refi64 refi64 reopened this Jun 20, 2016
@refi64
Copy link
Collaborator

refi64 commented Jun 20, 2016

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

@phase
Copy link
Owner Author

phase commented Jun 20, 2016

What use cases does only removing adjacent duplicates have?

@refi64
Copy link
Collaborator

refi64 commented Jun 26, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants