r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

[unknown: 5]
18-Jun-2008
[10644]
I think we can.  One that can probably accomodate much more.
Henrik
18-Jun-2008
[10645x2]
I would want to put all values that are going to be tested in a block.
a < [1 2 3 4]
[unknown: 5]
18-Jun-2008
[10647x2]
Would be nice if we use op! values as an argument to functions.
yeah that is what I initially wanted to do Henrik.
Henrik
18-Jun-2008
[10649]
I remember from my HP48 calculator that any numbers put in a block, 
could be operated on like that. But I think this is the beginnings 
of vector operations, which is a big area that should be done right.
[unknown: 5]
18-Jun-2008
[10650]
My function is actually very restricted in that it looks for the 
op! as the second to last value and the comparator as the last item.
Henrik
18-Jun-2008
[10651]
because I would also like to see:

>> 1 + [2 3 4 5]
== [3 4 5 6]

in R3 there are ways to do this with a bit more code.
[unknown: 5]
18-Jun-2008
[10652x2]
I could make that change to my function and easily accomodate that.
No outside of a single block though.
Henrik
18-Jun-2008
[10654]
I would love to see it in R3, but so far nothing from Carl WRT this 
particular feature. I think it might complicate op! way too much.
[unknown: 5]
18-Jun-2008
[10655x7]
I'm sure we can do something in the mezz sense once R3 gets released.
Shouldn't < > and = return as a logic values as well as being op 
values?
>> logic? get to-word "<"
== false
>>
I guess because it doesn't return true or false until it operates 
on something it wont return a logic value.  But maybe we should at 
least subclassify some operators to distingish them more.
some modifications made:
op+: func [blk /local op args arg blk2 blk3][
    op: first back back tail blk
    blk3: copy []
    arg: last blk
    if word? :arg [arg: get :arg]
    args: copy/part blk find blk op
    blk2: reduce [op arg]
    foreach item args [
        insert blk2 item
        if item: attempt [do blk2][

            either find form blk charset "<>=" [return item][append blk3 item] 
              
        ]
        remove blk2
    ]
    if not empty? blk3 [return blk3]
    false
]
>> op+ [1 2 3 4 + 1]
== [2 3 4 5]
Henrik
18-Jun-2008
[10662]
what you return is that the datatype is op!, not logic!, so logic? 
returns false.
[unknown: 5]
18-Jun-2008
[10663x4]
>> op+ [1 2 3 4 > 2]
== true
yeah I know I thought it would return logic and op depending on the 
test.
would be nice to have lop?
lop? - returns true or false if operator returns logic values.
Henrik
18-Jun-2008
[10667x2]
what do you mean?
ok
[unknown: 5]
18-Jun-2008
[10669]
lop? would be a function
Henrik
18-Jun-2008
[10670]
well, you wouldn't know without running actual tests with the operator.
[unknown: 5]
18-Jun-2008
[10671x2]
yeah you can
just like I do in the function above that I wrote.
Henrik
18-Jun-2008
[10673]
please explain, because I can't see where you do that. :-)
[unknown: 5]
18-Jun-2008
[10674x4]
I'm just checking the charset
all the ones that return logic are those operators that are or have 
in their form the characters "<" ">" or "="
lop?: func ['op][if find form op charset "<>=" [return true] false]
>> lop? +
== false
>> lop? <
== true
Henrik
18-Jun-2008
[10678]
I see.
[unknown: 5]
18-Jun-2008
[10679x3]
seems handy to me.
could be modified to become a true mezz
;a bit revised:

lop?: func ['op][if all [op? get op find form op charset "<>="] [return 
true] false]
Gregg
18-Jun-2008
[10682]
You can sort of trick your way around things with ops in most cases. 
e.g.

	>> fn: func ['op a b] [op: get op  op a b]
	>> fn < 1 2
	== true


But I avoid doing that. It ends up not being worth it, IMO, when 
you start to reuse things, generate code, etc. Just use func alternatives.
[unknown: 5]
18-Jun-2008
[10683]
heh but cool Gregg.
Chris
19-Jun-2008
[10684x2]
; Here's a thought:

	any-where: func [series [block!] test [block!]][
		foreach value series compose [if (test) [break/return value]]
	]

	probe any-where [1 2 3 4][value > 4]
	probe any-where [1 2 3 4][value >= 4]
	probe any-where [1 2 3 4][value < 4]


; I know it's a two block solution, but it's pretty language friendly. 
 You can recycle tests too:

	test: [value > 4]
	probe [1 2 3 4] :test
	probe [5 6 7 8] :test
Oops, forgot the function at the end there...
[unknown: 5]
19-Jun-2008
[10686]
Very nice Chris!
Anton
20-Jun-2008
[10687]
It's kind of like an "apply-any".
Henrik
21-Jun-2008
[10688]
simple problem:

>> a: [1 2 3 4 5]
== [1 2 3 4 5]
>> b: at a 3
== [3 4 5]
>> a
== [1 2 3 4 5]
>> b
== [3 4 5]
>> remove a
== [2 3 4 5]
>> b

== [4 5] ; I wonder if it's possible to make the index "sticky" at 
[3 4 5] in a relatively simple way. If it were, that would be very 
cool.
Graham
21-Jun-2008
[10689]
copy it first!  :)
Henrik
21-Jun-2008
[10690]
nope, it has to be the same series
Graham
21-Jun-2008
[10691]
and if you copy the index? as well?
Henrik
21-Jun-2008
[10692]
it must be the same series
Chris
21-Jun-2008
[10693]
Unless this is a feature request, you'll need an alternative to remove...