World: r3wp
[Core] Discuss core issues
older newer | first last |
BrianH 25-Jun-2010 [17152] | Sorry, I've been getting the AltME freezes again. It's affecting my typing. |
Fork 25-Jun-2010 [17153x2] | Regardless of other decisions, I feel like it's important to preserve the property that (a + b) = (b + a), as addition is... er, what's the word, commutative? |
50% + 10% should be 60%, but 50% + 10 should equal 10 + 50% no matter what one decides otherwise. | |
BrianH 25-Jun-2010 [17155] | Yes, I had forgotten the word, thanks. Unfortunately, the mathematical intuition is not commutative. |
Fork 25-Jun-2010 [17156x2] | Well that sounds more like linguistic intuition than mathematical intuition. |
I didn't feel like saying percent again | |
BrianH 25-Jun-2010 [17158x2] | Intuition is a bit of misnomer here. What you are really saying is "expected behavior". And that is always in the eye of the peoson doing the expecting. |
Great, now I have AltME freezes and a cat that is jealous of my computer - double whammy to my typing. | |
Fork 25-Jun-2010 [17160x6] | Natural programming is an interesting research area: http://www.google.com/search?hl=en&source=hp&q=10+%2B+50%25&aq=f&aqi=h1g10&aql=&oq=&gs_rfai= |
They get lots of people in and give them a box of fruit containing apples, oranges, pears | |
And ask like hundreds of people "go to the box and bring me back something that's not an apple or a pear" | |
And no one (who isn't a snarky programmer) brings back a pear. | |
How much of this is cultural and how much is some deep embedded pattern instinct a la X bar theory is tough to say http://en.wikipedia.org/wiki/X-bar_theory | |
But if things like X bar theory and these studies have merit, one actually can say that "right answers" aren't necessarily as fluid as being in the eye of a particular beholder as we might guess. | |
BrianH 25-Jun-2010 [17166] | Or who is from a culture with a language that assumes that or is inclusive. You haven't worked with many people for whom non-Western languages are their primary thought-shaping languages, I take it. |
Fork 25-Jun-2010 [17167x2] | Of course even then it's only right in a context, the context of human programmers... a time which will likely be coming to a swift end. :) |
Moving to "Chat" | |
Graham 25-Jun-2010 [17169] | go to the box and bring me back something that's not an apple Nor a pear |
BrianH 25-Jun-2010 [17170] | We need parentheses grouping of statements in English :( |
Graham 25-Jun-2010 [17171] | The english language is a bit loose ... and since the incorrect way of saying things is so common, one assumes that what's the speaker meant |
BrianH 25-Jun-2010 [17172] | Correctness is in the eye of the beholder :) |
Gregg 26-Jun-2010 [17173] | Fork, I would consider your desired behavior for an INCR function. |
Henrik 2-Jul-2010 [17174] | what's the quickest way to determine whether a series is past end in R2 and then handle it? |
Pekr 2-Jul-2010 [17175] | tail? |
Henrik 2-Jul-2010 [17176] | that is not accurate enough |
Sunanda 2-Jul-2010 [17177] | Why not? Is (index? s) > length? s any more accurate? |
Henrik 2-Jul-2010 [17178x2] | oh well, used this: all [series? :value greater? index? :value length? head :value] |
Sunanda, didn't see your post, but thanks, it's what I use. | |
Geomol 2-Jul-2010 [17180x2] | Quickest for what you test for might be: and series? s tail? s |
As a side note, I noticed, TAIL? and EMPTY? is the same. So you can also write the above as: and series? s empty? s Is it wise, that TAIL? and EMPTY? does the same? Maybe EMPTY? should return false, if the series holds elements, even if you're at the tail. | |
BrianH 2-Jul-2010 [17182x8] | AND is an op, thus infix, and doesn't have shortcut evaluation. This means that you should use AND~ instead of AND if you want prefix, but it will still fail if s is a datatype that is not compatible with EMPTY? because EMPTY? s will still be called even if SERIES? s is false. |
Henrik, can you post some code that will make a series reference that is past the end of a series? I'm having trouble making one that works consistently, and neither your INDEX? method or EMPTY? will work. REBGL keeps adjusting the index returned by INDEX?. | |
>> b: next a: "a" == "" >> index? b == 2 >> remove a == "" >> index? b == 1 ; adjusted >> insert a "1" == "" >> index? b == 2 ; and back again | |
In R3 they stay consistent, and there is an action PAST? to tell whether an index is past the end. >> b: next a: "a" == "" >> remove a == "" >> index? b == 2 ; not adjusted >> past? b == true In R2 I don't even see how to write this in mezzanine without temporarily appending something on the end of the series (a single element will do) and seeing if the index adjusts, then removing what you appended. Like this: >> b: next next next a: "abc" == "" >> clear a == "" >> also (index? b) < (append b "1" index? b) clear back tail b == true ; past end >> b: "" == "" >> also (index? b) < (append b "1" index? b) clear back tail b == false ; not past end, but Henrik's method, and EMPTY? will both return true. | |
Still, the temporarily appending method would be sufficient to backport a PAST? workaround, so I'll write one for R2/Forward. | |
Here's the source to the backport: past?: func [ "Returns TRUE if a series index is past its tail." series [series!] ; gob! port! ][ also (index? :series) < (insert tail :series "1" index? :series) clear back tail :series ; Undo the modification ] ; Note: Native in R3, and non-modifying. No ports because you can't undo the ; insert. INDEX? doesn't stay consistent with past-tail references in R2. | |
Submitted to R2/Forward. | |
Thanks, I had forgotten PAST? :) | |
Henrik 2-Jul-2010 [17190x2] | I'm not sure I would want the series to be modified as the case where PAST? is true could be for an indication of the series in a debug UI, rather than the actual use of the series. Interesting that you had so much trouble producing the problem. |
ah, you had trouble, because you were removing an element before the INDEX?, not after the INDEX?. >> b: "abc" == "abc" >> b: next next b == "c" >> clear back b ; does not modify INDEX? == "" >> b == ** Script Error: Out of range or past end ** Near: mold b >> index? b == 2 ; works every time | |
BrianH 2-Jul-2010 [17192] | You are also removing an element before the index, but not from the beginning. Apparently clearing from somewhere other then the beginning of the series breaks the auto-adjusting (which shouldn't be happening anyways). PAST? works the same either way. |
Ladislav 3-Jul-2010 [17193x9] | It was unfortunate to adjust the result of INDEX? function, since we actually obtain a wrong value this way. Auto-adjusting is not broken in the case Henrik posted. |
>> b: "abc" == "abc" >> b: next next b == "c" >> index? b == 3 >> clear back b == "" >> index? b == 2 | |
Nevertheless, as said above, I consider the auto-adjustment idea "broken". | |
past?: func [ "Returns TRUE if a series index is past its tail." series [series! gob! port!] ][ (index? :series) = (index? back :series) ] ; Note: INDEX? doesn't stay consistent with past-tail references in R2. | |
correction: past?: func [ "Returns TRUE if a series index is past its tail." series [series! gob! port!] ][ and~ not same? head? :series :series (index? :series) = (index? back :series) ] ; Note: INDEX? doesn't stay consistent with past-tail references in R2. | |
Yet another variant: past?: func [ "Returns TRUE if a series index is past its tail." series [series! gob! port!] ][ and~ (index? :series) = (length? head :series) not same? tail? :series :series ] ; Note: INDEX? doesn't stay consistent with past-tail references in R2. | |
past?: func [ "Returns TRUE if a series index is past its tail." series [series! gob! port!] ][ and~ (index? :series) = (length? head :series) not same? tail :series :series ] ; Note: INDEX? doesn't stay consistent with past-tail references in R2. | |
(the last is a correction of the one preceding it) | |
Simplification: past?: func [ "Returns TRUE if a series index is past its tail." series [series! gob! port!] ][ not same? :series skip :series 0 ] ; Note: INDEX? doesn't stay consistent with past-tail references in R2. | |
older newer | first last |