World: r3wp
[Rebol School] Rebol School
older newer | first last |
BrianH 2-Jan-2009 [1132] | 22 to 33 milliseconds, depending on input. |
Steeve 2-Jan-2009 [1133] | it's a shame 'either has a so verbose form ;-) |
BrianH 2-Jan-2009 [1134] | This isn't C :) |
Steeve 2-Jan-2009 [1135x3] | nite Janko |
it"s hard work to optimize such short mezzanine | |
but it's funny too | |
BrianH 2-Jan-2009 [1138] | Indeed it is both, but well worth it :) |
Steeve 2-Jan-2009 [1139] | for my personnal use, i would have an option to modify the input serie instead of creating a new one |
BrianH 2-Jan-2009 [1140x2] | The R3 FOREACH is used for that. |
Still, good idea :) | |
Steeve 2-Jan-2009 [1142] | an /keep refinement on map ? |
BrianH 2-Jan-2009 [1143] | /no-copy |
Steeve 2-Jan-2009 [1144x2] | i want to see :) |
i try... | |
BrianH 2-Jan-2009 [1146x2] | I did some testing and found that, as a general practice, the /into option leads to code with less overhead than the /no-copy option. |
The implementation tends to be smaller too, as change-in-place code looks very different than fill-something code. | |
Steeve 2-Jan-2009 [1148] | hum, really ? |
BrianH 2-Jan-2009 [1149] | Using /into for your functions leads you towards reusable buffers and incremental building. The /no-copy option tends towards template copying. I mean, as the option is used generally. |
Steeve 2-Jan-2009 [1150] | do you mean by default map should do change ? |
BrianH 2-Jan-2009 [1151] | Let me show you MAP with /into. |
Steeve 2-Jan-2009 [1152x2] | oki |
not so easy ? :) | |
BrianH 2-Jan-2009 [1154x3] | map: func [ [throw] "Evaluates a block for each value(s) in a series and returns them as a block." 'word [word! block!] "Word or block of words to set each time (local)" data [block!] "The series to traverse" body [block!] "Block to evaluate each time" /into "Collect into a given series, rather than a new block" output [series!] "The series to output to" ] [ unless into [output: make block! either word? word [length? data] [divide length? data length? word]] foreach :word data reduce [:insert :tail output to paren! body output ] |
Sorry, forgot the ] after the foreach | |
Sorry again, wrong semantics. | |
Steeve 2-Jan-2009 [1157] | hum, i see now, you don't update the input data. |
BrianH 2-Jan-2009 [1158] | The /into option is supposed to have INSERT semantics, not INSERT TAIL. |
Steeve 2-Jan-2009 [1159] | really ? i don't see what is the need |
BrianH 2-Jan-2009 [1160] | INSERT semantics are the most general. You can add the TAIL on call. |
NickA 2-Jan-2009 [1161x2] | <-- cowering in the corner, but totally enjoying this demonstration :) |
clap ... clap ... clap ... | |
BrianH 2-Jan-2009 [1163x2] | I'm going to do a study of all of the REBOL functions that generate series (even natives) and determine which would benefit from the /into option, then get it added. It might be tricky to modify actions though. REDUCE and COMPOSE are getting the /into option. |
This is one of my R3 tasks. We'll backport where possible. | |
NickA 2-Jan-2009 [1165] | BrianH, how many of you are there actually working on R3 code? |
BrianH 2-Jan-2009 [1166x2] | It varies, depending on the task. Right now many of us are taking a break and Carl is working on the development infrastructure. Other times there are a few in some cases, many in others. We'll be able to handle more after Carl's RebDev work. |
Which is proceeding nicely :) | |
NickA 2-Jan-2009 [1168] | That's great to hear :) I wish I could help, but I don't have the chops. Maybe testing, promotion, things like that... |
BrianH 2-Jan-2009 [1169] | We need those chops too :) |
Steeve 2-Jan-2009 [1170x2] | just a thing Brian, insert (without tail) will revert the result and cause overhead by pushing previous added values in the loop... |
missing something... | |
BrianH 2-Jan-2009 [1172] | No, it's a different problem: You have to assign the result of the insert to output as you go along. This leads us to another variable captre problem. |
Steeve 2-Jan-2009 [1173x2] | ok, i see now |
but we should use change to do that job, not insert | |
BrianH 2-Jan-2009 [1175] | No, it doesn't change in place, and the /into should be able to insert in the middle of a provided series if necessary. |
Steeve 2-Jan-2009 [1176] | change replace old values in output and expand the output serie if needed |
BrianH 2-Jan-2009 [1177x2] | Insert will also expand, and we don't want to replace any existing values if any. |
If you want to replace, clear the series before providing it. | |
Steeve 2-Jan-2009 [1179] | ok but i'm not convinced by the interest to be able to insert in the middle of a serie. |
Steeve 3-Jan-2009 [1180] | ok but i''m not convinced by the interest to be able to insert in the middle of a serie |
BrianH 3-Jan-2009 [1181] | This trick only works if it is pervasively implemented and consistent. It is a cross-cutting language design issue. |
older newer | first last |