World: r4wp
[#Red] Red language group
older newer | first last |
kensingleton 17-Nov-2012 [3953x2] | Andreas - the problem I have with ordinals is how do you do mathematics on them eg. 3 + -3rd ? Index manipulation uses ingteger! and so is mathematically modifiable |
Anyway - good luck Doc on sorting this one out - and thanks again for doing Red it is very exciting | |
Kaj 17-Nov-2012 [3955] | I like Andreas' proposal |
Andreas 17-Nov-2012 [3956x5] | Ken, re maths for ordinals: just a matter of how you want to define it. |
-3rd + 3 == 1st | |
1st -1 = -1st, -1st + 1 = 1st, 1st + 0 = 1st | |
The more interesting question is how ordinals map to integers :) That basically requires a decision of how you want to do indexing with integers, then it's easy as well. | |
One possibility. Another would be to have ordinals purely as syntactic convenience, and not allow arithmetics with them. | |
kensingleton 17-Nov-2012 [3961x2] | Ok - thanks for the clarification Andreas - that makes sense now. I think maths usage would be essential for use cases such as the one Brian put forward - he mentioned at least addition and modulo. |
Anyway - I have shared what I felt I needed to say. I will now leave it to the guru's to decide the way forward on this matter. My knowlege of Rebol is not sufficient to push any particular solution. | |
Ladislav 17-Nov-2012 [3963x4] | It's just a dialect for going in the opposite direction - it is not, in fact. (PICK SERIES INDEX) is just an evaluation of a function, not a "dialect" |
I don't buy the no right" argument. Romans had subtraction without 0. It was a bad idea, but it was possible." Yes, but -1 is not "subtraction", it is a value. | |
Now, try to come up with a way to explain to newbies that this phantom hole in a series makes sense, or is a good idea. - yes, a good illustration from a beginner/documentation/education POV. Also, what is exactly as bad even for experienced users is that it disrespects arithmetic making simple index arithmetic (ADD INDEX OFFSET) not usable. | |
...it means that 0 doesn't exist, like we're programming in Roman. - again, a cute formulation. I bet that there is no "programming in Roman", the word "algorithm" is from the world where 0 does exist. | |
DocKimbel 17-Nov-2012 [3967] | Kensingleton: thank you very much for your inputs. Having different point of view is helpful. |
Kaj 17-Nov-2012 [3968x3] | It's just a dialect for going in the opposite direction" - it is not, in fact. (PICK SERIES INDEX) is just an evaluation of a function, not a "dialect"" |
False. PICK SERIES INDEX is usually evaluated as DO dialect. It could also be evaluated as any other dialect | |
SERIES/-1 is not even function evalutation in the DO dialect, it's path evaluation | |
DocKimbel 17-Nov-2012 [3971] | Also, what is exactly as bad even for experienced users is that it disrespects arithmetic making simple index arithmetic (ADD INDEX OFFSET) not usable. I guess you're not talking about R2, which index arithmetic has proven to be very usable in last twelve years (at least) through countless *working* user apps. |
Ladislav 17-Nov-2012 [3972] | My Understanding of Series: A contiguous collection of boxes sequentially numbered in ascending order starting at 1. - this is correct only for series I would call "Head Series", i.e. such series that are their own heads. |
BrianH 17-Nov-2012 [3973x2] | Agreed, "not usable" is a little harse. Bad and awkward, but once you work around that it is usable. |
harse -> harsh | |
Ladislav 17-Nov-2012 [3975] | I guess you're not talking about R2, which index arithmetic has proven to be very usable in last twelve years (at least) through countless *working* user apps. - "working" are only the ones limiting the index arihmetic to some special cases. Those not limiting themselves to such cases are not working. |
Andreas 17-Nov-2012 [3976x2] | You actually have that you have to work around it, otherwise R2 will bite you hard (and silently). |
... have to know* that you have to work around it ... | |
Ladislav 17-Nov-2012 [3978x12] | You actually have that you have to work around it, otherwise R2 will bite you hard (and silently). - yes, "you have to work around it" is (for me) a different formulation equivalent to "not working" |
I am able to do any work-arounds necessary at any time. However, I prefer to use a working solution. | |
Knowing Carl's preferences, I did not insist on switching to 0-based indexing. However, for the sake of arithmetic, I at least convinced him to switch to "continuous indexing". | |
Here is a task I consider relevant: 1) define a function obtaining a series S and an index I and yielding an index J such that PICK S I would be equivalent to PICK HEAD S J 1a) do the task in R2 1b) do the task in R3 1c) do the task in R4 with zero-based indexing | |
This is my solution of 1c): head-index?: func [s [series!] i [integer!]] [i + index? s] | |
(that is what I call "working index arithmetic") | |
This is my solution of 1b): head-index?: func [s [series!] i [integer!]] [i - 1 + index? s] | |
(again, a case of "working index arithmetic") | |
(although a bit more complicated than the 1c case) | |
1a) is a task for people stating that "zero does not exist" | |
...and also for people stating that "index arithmetic *is* working in R2" | |
Note that the difference between 1c) and 1b) seems to demonstrate why 0-based indexing may be found more convenient than 1-based indexing | |
PeterWood 17-Nov-2012 [3990] | I know this would be consiidered a "workaround" but head-index?: func [s i] [i - (index? head s) + (index? s)] |
Ladislav 17-Nov-2012 [3991x2] | Testing your implementation with: 1 = index? head s 0 = i 2 = index? s i get: 1 = head-index? s i , which is incorrect |
(your solution is actually 1b, not 1a) | |
BrianH 17-Nov-2012 [3993] | It would work for 1c too. |
Ladislav 17-Nov-2012 [3994x2] | yes |
(but in any of those cases my solutions are simpler) | |
Kaj 17-Nov-2012 [3996] | In REBOL, we have an important design rule to optimise for the common case. Your exercise is contrived, while R2 still optimises for the common cases |
Ladislav 17-Nov-2012 [3997x2] | OK, for Kaj: I do not insist the solution has to be "optimized". |
just working will be OK | |
Kaj 17-Nov-2012 [3999] | Another case of the common case is that Red's intended common audience is common people, not mathematicians. While R3 "works" for mathematicians, R2 is the one that works for common people |
Ladislav 17-Nov-2012 [4000] | So, if we consider Peter Wood a "common man"(no offense intended), do you state that his solution works? |
Kaj 17-Nov-2012 [4001] | I already stated I'm not talking about your mathematical exercise, but about common programming patterns in REBOL, such as series/-1 |
Ladislav 17-Nov-2012 [4002] | OK, so you feel offended that Peter considered my exercise worth trying? |
older newer | first last |