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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rank Polymorphism #55

Open
booniepepper opened this issue Jul 28, 2023 · 3 comments
Open

Rank Polymorphism #55

booniepepper opened this issue Jul 28, 2023 · 3 comments
Labels
idea Ideas to ponder
Milestone

Comments

@booniepepper
Copy link
Collaborator

Why not?

Currently these would be errors, but they could easily be rank polymorphic:

» [ 1 2 3 ] 1 + pl
[ 2 3 4 ]
» [ "it's" "too" "quiet" ] upcase pl
[ "IT'S" "TOO" "QUIET" ]
@booniepepper booniepepper added the idea Ideas to ponder label Jul 28, 2023
@booniepepper booniepepper added this to the 2.0 milestone Jul 31, 2023
@cadrgtsecond
Copy link

cadrgtsecond commented Nov 24, 2023

Technically this isn't rank polymorphism since dt arrays don't have rank i.e They cannot be multi-dimensional. However they do have depth(i.e nesting). Although rank could be useful for dealing with tabular data

Also this means you will need some kind of rank/depth modifiers as well functions to control it e.g

example1010⥊↕100 # Assume this is something useful
┌─                               
╵  0  1  2  3  4  5  6  7  8  9  
  10 11 12 13 14 15 16 17 18 19  
  20 21 22 23 24 25 26 27 28 29  
  30 31 32 33 34 35 36 37 38 39  
  40 41 42 43 44 45 46 47 48 49  
  50 51 52 53 54 55 56 57 58 59  
  60 61 62 63 64 65 66 67 68 69  
  70 71 72 73 74 75 76 77 78 79  
  80 81 82 83 84 85 86 87 88 89  
  90 91 92 93 94 95 96 97 98 99# plus-insert
Sum+˝

Sum example # Columnwise450 460 470 480 490 500 510 520 530 540Sum¯1 example # Rowwise45 145 245 345 445 545 645 745 845 945 ⟩

(Sum) example # The total sum
4950

I would recommend reading the J documentation on Rank or spending some time with an array language to get a feel for it

@cadrgtsecond
Copy link

IMO rank is perfectly suited for the language. It would finally allow shell invocations to mirror scripts. Shell invocations would just be Array -> Array

@booniepepper
Copy link
Collaborator Author

Thanks for chiming in, the rank vs depth distinction is good to call out. I guess I was thinking more of depth as a proxy for rank

I think a proper rank really only makes sense when getting into math operations, so I might save it for later. I don't know what rank would mean for text processing, for example, and that's more of dt's bread and butter

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

No branches or pull requests

2 participants