World: r3wp
[Rebol School] Rebol School
older newer | first last |
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 [1181x6] | This trick only works if it is pervasively implemented and consistent. It is a cross-cutting language design issue. |
cross-cutting = Aspect-Oriented Programming term. | |
It means that function options of the same name should be implemented consistently and to whatever function applicable. | |
(in this case, that is what it means) | |
A REBOL example is the /only option. | |
The /only option means something different each time, but in general its usage is consistent: - Do the sensible thing by default. - Do the advanced thing when /only is chosen. Every function with an /only option behaves this way. | |
Steeve 3-Jan-2009 [1187x2] | where is it already used ? |
i mean /into | |
BrianH 3-Jan-2009 [1189x3] | In functions in R3, starting with COLLECT. |
It will be used in many functions, and natives. REDUCE and COLLECT /into get rid of chained inserts, for instance. It also reduces series copy overhead. It will be a big deal when we hahve rolled it out across the board. | |
hahve -> have | |
Steeve 3-Jan-2009 [1192] | ok |
BrianH 3-Jan-2009 [1193] | I think MOLD and FORM should get /into as well. |
Steeve 3-Jan-2009 [1194] | and reduce ? |
BrianH 3-Jan-2009 [1195x2] | I mentioned REDUCE and COLLECT already :) |
Sorry, the last two mentions of COLLECT I meant COMPOSE :) | |
Steeve 3-Jan-2009 [1197] | erf |
BrianH 3-Jan-2009 [1198] | It's been a long day. |
Steeve 3-Jan-2009 [1199] | i have problems with my connexion, see you laters, nite... |
BrianH 3-Jan-2009 [1200] | Good night. |
[unknown: 5] 3-Jan-2009 [1201] | If you guys get some good mezzanines please post them on my Mezzanine thread. http://www.tretbase.com/forum/viewtopic.php?f=8&t=30Also, if anyone wants to make the current ones posted more efficient please do. |
Gregg 3-Jan-2009 [1202] | If you're looking for HOFs, and other advanced information, check out Ladislav's articles: http://www.fm.tul.cz/~ladislav/rebol/ |
Sunanda 3-Jan-2009 [1203] | Or http://www.rebol.org/view-script.r?script=hof.r |
Geomol 3-Jan-2009 [1204] | REBOL is so nice, that if you miss some cool feature found in some other language, like the MAP function, you can make it in a line of code. We should add a wiki with such cool things from other languages, and how you do it in REBOL. |
Steeve 3-Jan-2009 [1205x4] | As someone stated, what about a mezzanine thread for new proposal and discussions... ? thinking about [fold] (aka reduce) , i don't know if it's really intersting to have it as mezzanine, cause it's really short: fold y [1 2 3 4][x: x + y] x: 0 repeat y [1 2 3 4][x: x + y] |
wrong: >>x: 0 >>foreach y [1 2 3 4][x: x + y] | |
[foreach] is our HHOF (higher higher order function) | |
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]] head foreach :word data compose [output: (:insert) output (to paren! body)] ] >> map x [1 2 3 4][x + x] == [2 4 6 8] >> map [x y][1 2 3 4][x + y] == [3 7] >> map/into [x y][1 2 3 4][x + y][10 11 12] == [3 7 10 11 12] But still a problem with the output var collision | |
older newer | first last |