World: r3wp
[Core] Discuss core issues
older newer | first last |
[unknown: 5] 8-May-2009 [13663x3] | Wouldn't it be nice to do: series: [1 2 3 4 5 6 7 8 9 10] find series > 5 |
such that it returns: [6 7 8 9 10] | |
Even extend that to use CHAR values also. | |
Maxim 8-May-2009 [13666x2] | I agree that adding a refinement to include a compare func would be pretty usefull! |
maybe some other func provides this and we're not thinking about it. | |
[unknown: 5] 8-May-2009 [13668x2] | Seem I'm always wanting this functionality and would be a very useful upgrade. |
Could be Maxim, I often put something down - only to find Gabriele or Ladislav showing me another way. | |
Janko 8-May-2009 [13670] | there is something like filter function I think (or you can make one that takes values and expression) |
[unknown: 5] 8-May-2009 [13671] | I know we can easily build a function to do this but it seems so well suited to the 'find function. |
Maxim 8-May-2009 [13672] | find/match series (6 = pick serie 1) would make a lot of sense to me. |
kcollins 8-May-2009 [13673] | In R3: remove-each x series [x <= 5] |
[unknown: 5] 8-May-2009 [13674x2] | We ave remove-each in R2 also but that is a bit different as it is doing removal - I don't want something removed just a subset returned. |
I submitted my request to cure-code. | |
Maxim 8-May-2009 [13676] | yess remove actuall modifies the series being given, find just changes its offest. |
Henrik 8-May-2009 [13677] | it would be more like extract with a /find index. |
kcollins 8-May-2009 [13678] | You could copy the series first, although obviously this impacts performance. |
[unknown: 5] 8-May-2009 [13679] | http://curecode.org/rebol3/ticket.rsp?id=781 |
Henrik 8-May-2009 [13680] | have we had a discussion about a variable /skip based on FIND? I think it's a good idea in general. |
[unknown: 5] 8-May-2009 [13681] | not sure. |
Janko 8-May-2009 [13682] | I think its a good idea to ahve find like that (so that it gives subset) but expression would have to be a block so you can put any code inthere and things are systematic |
Maxim 8-May-2009 [13683] | but even extract creates a new series, we just want to change the offset, its much more efficient in all cases... and yess I would have used that VERY often. |
[unknown: 5] 8-May-2009 [13684] | I think everyone would use it very often. I can't believe we haven't created it yet. |
Maxim 8-May-2009 [13685x2] | basically its exactly like sort's /compare argument. |
like /skip, maybe the /compare refinement could become more generalized. this would be a logical complement to the flat record concept which /skip enables... wrt SQL, in some cases /compare is used as a where clause, other times its the argument to TOP, somethimes its used as the ORDER-BY, its very symmetric and much simpler to have the same refinement for all of these IMHO | |
[unknown: 5] 8-May-2009 [13687] | Would be nice to add that functionality to those other functions that could use it. |
kcollins 8-May-2009 [13688] | So the desired feature is to return the series at the position of the first element which meets a specified condition? |
[unknown: 5] 8-May-2009 [13689x2] | yes. |
since find already has /reverse that would be nice to have it use that as well such as: find/reverse series > 3 | |
Maxim 8-May-2009 [13691] | there some details to consider for string parsing though... |
kcollins 8-May-2009 [13692] | You might want to revise the Curecode ticket to be more explicit. As it is now I believe it is vulnerable to misinterpretation. |
Maxim 8-May-2009 [13693] | like how to handle /tail |
Anton 9-May-2009 [13694x4] | MAP is close to what you want. data: [1 2 3 4 5 6 7 8 9 10] map v data [either v > 5 [v][]] ;== [6 7 8 9 10] |
foronly: func [cond data][map v data compose [either (cond) [v][]]] foronly [v > 5] data ;== [6 7 8 9 10] foronly [even? v] data ;== [2 4 6 8 10] | |
(A better name for FORONLY would probably be FINDALL or something like that.) | |
It's related to COLLECT and I suppose "GATHER". | |
Janko 12-May-2009 [13698x2] | do any of you rebol gurus see a way to do something like coroutines / yield / generators with rebol - so far a lot was possible to be done in rebol on a library level because it can change it's own code and because primitives aren't really primitives, but I don't see how this could be done ( there is magical do/next but it would block until loop exits so for something like this example it won't work). I am not sure I know the exact definition of coroutines so I will give an simple fictional example.. ... retvieve-time: func [ node /local msg ] [ send-message node "get-time" while [ not msg: get-waiting-message ] [ yield ] print [ "the time is" msg ] ] append *processes* :retrieve-time retrieve-time *timer-node* forever [ foreach p *processes* [ continue p ] ] Yield returns controll from function, and next time continue is function continues at that point. I know the example isn't technically correct (for example when function exits it should be flagged and cleared from *processes* etc) , but just for illustration what I am asking |
I made progress with my simple actors library few weeks back but I still ahvent found time to make a blogpost about it.. it works nicely without something like yield and probably even has few advantages, but I am interested if somehow this can be made on top of rebol too | |
BrianH 12-May-2009 [13700] | R3 will have multitasking. For R2 you need to write your own interpreter, or switch the semantics (actors), or multiprocess. |
Robert 13-May-2009 [13701] | I will never remember the trick: How can I get an output of 12.30 instead of 12.3? |
[unknown: 5] 13-May-2009 [13702x2] | BrianH, R3 discussions should go in the Rebol3 group. |
(The hypocrisy). | |
Geomol 13-May-2009 [13704] | Robert, do you mean using money datatype? >> $12.3 == $12.30 or maybe something like >> append mold 12.3 "0" == "12.30" |
Robert 13-May-2009 [13705x8] | ah, I forget about money! in R2... thx. |
Next one: I need to construct a HREF="..." with some dynamic code. | |
compose [<a href="/rest-cart/ordet/ (to-string session/id) "> "Bezahlen" </a>] | |
Of course this doesn't work. But converting the TAG to strings and than combining it all didn't work too. | |
And why this: | |
>> rejoin [<a href="test"> "Test" </a>] == <a href="test"Test</a>> | |
This works but is ugly: | |
>> rejoin [<a href="test"> "Test" </a>] == <a href="test"Test</a>> | |
older newer | first last |