World: r3wp
[Core] Discuss core issues
older newer | first last |
GrahamC 28-Oct-2010 [220x3] | I'm going to have to use a loop :( |
I don't know why subtract does not work on blocks | |
foreach el set2 [ remove find set1 el ] | |
Maxim 28-Oct-2010 [223] | I tried yours and it didn't seem to work... but this definitely does: c: 0 blk: [ 1 2 3 1 2 3 1 4 ] unique remove-each i copy blk [ c: c + 1 not find (at blk c + 1) i] |
GrahamC 28-Oct-2010 [224x2] | I can't see why mine won't work ... |
since set2 is a unique version of set1, it will always find and always remove | |
Carl 28-Oct-2010 [226] | I've long considered + and - on blocks to be useful... but, would others agree? |
Maxim 28-Oct-2010 [227] | YES! |
GrahamC 28-Oct-2010 [228x2] | go for it! |
though I don't mind if we use 'subtract and 'add | |
Carl 28-Oct-2010 [230] | They're the same. |
Maxim 28-Oct-2010 [231x2] | there is also a really usefull missing "set" function duplicates: returns items in a series present multiple times in that series. without this function, right now there are many missing combinations. |
to get singletons: exclude blk duplicates block | |
GrahamC 28-Oct-2010 [233] | next you'll be asking for the ability to create combinations and permutations! |
Maxim 28-Oct-2010 [234] | well, AFAIK duplicates is probably the single most frequently re-requested series function I've seen in the years. |
GrahamC 28-Oct-2010 [235] | so return those in a block where there exists more than one? |
Maxim 28-Oct-2010 [236] | yep. |
GrahamC 28-Oct-2010 [237x2] | which is essentially what I was trying to do above |
what instances have you needed this? | |
Maxim 28-Oct-2010 [239x2] | but its so usefull in simplifying many other loops and algorithms. |
when managing data sets, you often want to know what is unique "within" that set. duplicates and singletons are often-required things you want to know about a data set. | |
GrahamC 28-Oct-2010 [241] | i guess make a wish on curecode for R3 |
Maxim 28-Oct-2010 [242x2] | yes... I just thought about that. |
I will. | |
GrahamC 29-Oct-2010 [244x3] | Has anyone a simple algorithm for calculating the last day of a month? Or is a lookup table easiest? get-end-month: func [ d [date!] /local tmp ][ tmp: d while [ tmp/month = d/month ][ tmp: tmp + 1 ] tmp ] |
get-end-month: func [ d [date!] /local tmp ][ tmp: d while [ tmp/month = d/month ][ tmp: tmp + 1 ] tmp - 1 ] | |
get-end-month: func [ d [date!] /local tmp ][ tmp: d tmp/day: 28 while [ tmp/month = d/month ][ tmp: tmp + 1 ] tmp - 1 ] | |
Gregg 29-Oct-2010 [247] | set 'last-day-of-month func [date /local d] [ d: date d/day: 1 d/month: d/month + 1 d: d - 1 d ] |
GrahamC 29-Oct-2010 [248] | nice |
Henrik 30-Oct-2010 [249] | >> append [] 'now/precise == [now precise] is there a better way? |
Sunanda 30-Oct-2010 [250] | Is this better? To get an unevaluated now/precise into a block: append [] [now/precise] |
Henrik 30-Oct-2010 [251x3] | possibly... |
found a different way, so won't be needed. | |
I wanted a nice way to produce fragmented message strings that will be translated later, using a TRANSLATE function. So I made this function: tell: func [blk /local out s] [ out: make string! 10000 parse blk [ any [ [ set s string! (append out translate s) | to any-type! copy code [to string! | to end] (append out to string! reduce [#"'" mold/only do code #"'"]) ] (append out #" ") ] ] join trim out #"." ] >> file: what-dir == %/c/program files/rebol/view/ >> tell ["File" file "cannot be found"] == {File '%/c/program files/rebol/view/' cannot be found.} | |
Ladislav 30-Oct-2010 [254] | >> append/only [] 'now/precise == [now/precise] |
Henrik 30-Oct-2010 [255] | interesting, thanks |
Gabriele 31-Oct-2010 [256] | Henrik, I don't think that's nice, because you can't really translate "File" and "cannot be found" separately. Don't expect all languages to have the same grammar structure etc. |
Henrik 31-Oct-2010 [257x2] | Gabriele, probably not, but the language system, I'm working with works like this. |
a better one would probably input the string like: File %1% cannot be found. Maybe I should do that... | |
Gabriele 31-Oct-2010 [259] | What I did for the network detective was "File <file> cannot be found." See SUBSTITUTE in http://www.colellachiara.com/soft/libs/utility.r |
Henrik 31-Oct-2010 [260] | ok, thanks |
Gabriele 31-Oct-2010 [261] | (I think that <filename> or %filename% etc. helps the translator a lot more than %1% or anything like that. Of course, Qtask uses %1%. :-) |
Henrik 31-Oct-2010 [262x2] | how do you determine the order without referring to the tag twice? |
ok, I see what you're doing.... | |
GrahamC 31-Oct-2010 [264x3] | Anyone got a suggestion on how to flatten the results of a SQL query. Got [ [ "xxx" ] [ "yyy" ] [ "zzz" ]] and want [ "xxx" "yyy" "zzzY ] |
now to-block form [ [ "xxx" ] [ "yyy" ] [ "zzz" ]] does not work ... due to Rebol evaluating the contents | |
sure I could iterate over the whole lot and create a new block ... | |
Andreas 31-Oct-2010 [267x2] | >> collect [foreach item [["xxx"] ["yyy"] ["zzz"]] [keep item]] == ["xxx" "yyy" "zzz"] |
Even simpler: >> map-each item [["xxx"] ["yyy"] ["zzz"]] [first item] == ["xxx" "yyy" "zzz"] | |
GrahamC 31-Oct-2010 [269] | heh .. not used map-each or collect before .. are these in R2 ? |
older newer | first last |