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

World: r3wp

[!REBOL3-OLD1]

Anton
31-Aug-2006
[1204x2]
Lots of English candidate words suffer because they don't imply copy, 
whereas in rebol this is important and it would be nice to distinguish 
between when we are copying and when we are not.
I think you are right. FOREACH is stepping through each value of 
the block unevaluated, then, expecting to be able to evaluate it 
successfully. But what if it is a function expecting arguments ?
JaimeVargas
31-Aug-2006
[1206x2]
;; New version does proper reduction


delimit: func [data [block!] /reduce /quoted /with separator  [string! 
char!]  /local result quote][
  if reduce [data: system/words/reduce data]
  unless empty? data [
    result: copy {}
    unless with [separator: ""]
    quote: either quoted [
        func[x][rejoin [{"} x {"}]]
    ][
        func[x][x]
    ]
    insert result quote form first data
    foreach value next data [
      insert insert tail result separator quote form value
    ]
    result
  ]
]
;; example

>> delimit/reduce/with [npa nxx square-root 4] " "  ;== "703 938 
2.0"
Anton
31-Aug-2006
[1208]
Note, if this is going to be Rebol3, then you should be able to use 
APPEND instead of INSERT TAIL without penalty.
JaimeVargas
31-Aug-2006
[1209x6]
Now we need a good name. I am not sure about glue. How about CONCAT
Another one is CHAIN
concatenate: 
verb [ trans. ] formal or technical 
link (things) 
together in a chain or series : some words may be concatenated, such 
that certain sounds are omitted.
Another optin is LINK
To summarize  we have: REJOIN, GLUE, CONCAT, CONCATENATE, CHAIN, 
LINK.
And DELIMIT
Henrik
31-Aug-2006
[1215x3]
'link? is already used, so it might be interpreted as 'link is somehow 
... linked to 'link? :-)
interpreted as if 'link is
weld?
Anton
31-Aug-2006
[1218]
Just looking at the Thesaurus:
http://thesaurus.reference.com/search?q=join&x=0&y=0
Some nice words:

adhere, affix, (agglutinate), cement, conjoin, fasten, fuse, leash, 
marry, wed, weld.
JaimeVargas
31-Aug-2006
[1219]
Do you want the added functionality of the DELIMIT above?
Henrik
31-Aug-2006
[1220]
jaime, yes that would be very nice
Anton
31-Aug-2006
[1221x3]
conjoin is cool, language root are like "delimit/with"
Ah yes, Jaime, I wanted to say "DELIMIT" lies to you when it is used 
without the /WITH refinement, because DELIMIT implies delimiters. 
If there aren't any delimiters, then it is lying.
So an idea I would like to explore is to split the functionality 
of DELIMIT into perhaps two functions. As this kind of operation 
is very common, I suggest that this will save lots of typing.
JaimeVargas
31-Aug-2006
[1224x2]
How will you split it.
The description I have for DELIMIT is "Returns a string! constructed 
from the chained values in the block."
Anton
31-Aug-2006
[1226]
Must think about that.
JaimeVargas
31-Aug-2006
[1227x2]
I should not that I am not attached to DELIMIT. It stated like with 
a different purpose, but now I see that is more generic than REJOIN. 
So I offer it after modifying it a bit.
I like the CONJOIN word.
Anton
31-Aug-2006
[1229]
Currently we use REJOIN for most things, and sometimes we miss being 
able to add delimiters, after that, the next functionality is probably 
the quoting.
JaimeVargas
31-Aug-2006
[1230x2]
But CONJOIN is not very common. I thinkn CONCAT will be more mnemonic 
for newbies.
Picking names is very hard. I kind of like to have all the functionality 
cram in one function, less words to remember. So I left the naming 
decision to the community, just hope the features of delimit are 
include in R3.
Anton
31-Aug-2006
[1232x2]
So I would drop the /WITH refinement and make it implicit in a DELIMIT 
or CONJOIN function... (maybe..)

1) rejoin/quoted [...]   ; <-- this is most similar to rejoin, or 
delimit without the /WITH

2) conjoin/quoted "," [...]    ; <-- this is like delimit/with/quoted 
 (and the non-optional "with" argument is specified first)
I dislike CONCAT because it is an abbreviation.
JaimeVargas
31-Aug-2006
[1234x2]
me too, but a lot of people knows it.
I am not sure I follow your points.
Anton
31-Aug-2006
[1236]
The first function, REJOIN, is like the current rebol REJOIN, except 
it now has your /QUOTED refinement.
JaimeVargas
31-Aug-2006
[1237]
I don't really see the reason for splitting features of the function.
Anton
31-Aug-2006
[1238]
The second function, CONJOIN, is like your DELIMIT, except with WITH 
refinement implicit.
JaimeVargas
31-Aug-2006
[1239]
I think is better to keep Rebol's lexicon short.
Anton
31-Aug-2006
[1240]
I think the /REDUCE refinement usually isn't needed (I could be wrong), 
because if you are not going to reduce the block then you already 
know what the result is.
JaimeVargas
31-Aug-2006
[1241]
>> delimit [1 1 / 2 ]  ;
== "11/2"

>> delimit/reduce [1 1 / 2]  ;
== "10.5"
Anton
31-Aug-2006
[1242]
I think functions that are used very often with certain combinations 
of refinements ought to be split.
JaimeVargas
31-Aug-2006
[1243]
That can be changed easily.
Anton
31-Aug-2006
[1244]
If we make the right decisions about which functions are important 
enough to have their own word, we free ourselves with clearer code 
etc. Imagine if there was no DO function, but that functionality 
was a refinement of LOAD or REDUCE   --->    We would write REDUCE/DO 
 all the time.
JaimeVargas
31-Aug-2006
[1245]
The default behaviour could be to reduce.
Anton
31-Aug-2006
[1246]
That might be an idea. Closer to current rebol behaviour too.
JaimeVargas
31-Aug-2006
[1247]
delimit [1 1 / 2] ;== "10.5"
delimit/literal [1 1 / 2] ;== "11/2"
Anton
31-Aug-2006
[1248x2]
Yes, I think that's better. That refinement is the "weakest" of the 
three.
Please excuse me if I'm a little hazy today. Feeling a bit quantum 
mechanical today.
Tomc
31-Aug-2006
[1250]
I like 'conjoin
Henrik
31-Aug-2006
[1251]
anton, don't go phase into higher dimensions jus yet. :-)
Anton
31-Aug-2006
[1252]
it is ... too late... for me...
Pekr
31-Aug-2006
[1253]
but then also think about form vs reform