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

World: r3wp

[Core] Discuss core issues

Graham
19-Jun-2005
[1339]
t 'From => ?
PhilB
19-Jun-2005
[1340x2]
>> t: func [ip-val [word!]] [
[        switch/default ip-val
[        [
[                'From [print "A"]
[                'To [print "B"]
[            ]
[        [print "C1"]
[    ]
>>
>> t 'From ; should print "A"
C1
>>
shouldnt that have printed A rather than C1
Graham
19-Jun-2005
[1342]
>> t: func [ip-val [word!]] [
[        switch/default ip-val
[        [
[                From [print "A"]
[                To [print "B"]
[            ]
[        [print "C1"]
[    ]
>> t 'from
A
PhilB
19-Jun-2005
[1343]
OK ... so I dont need the "'" before the word ..... thanks
Graham
19-Jun-2005
[1344x3]
I remember being caught on that one once before.
I note that the parts of  dates, times, tuples etc are accessible 
using path notation.
Why not email! as well?
I would suggest that email/1 should be the part before the "@", and 
email/2 the bit after.
Then email/2/1 would access the first bit before the "." etc.
Allen
19-Jun-2005
[1347]
Graham: Are you asking for  email/1 & email/2 to map to the current 
email/user and email/host  refinements ?
Graham
19-Jun-2005
[1348x2]
oh no!
where was this documented??
Tomc
19-Jun-2005
[1350]
under datatypes  http://www.rebol.com/docs/core23/rebolcore-16.html#section-2.3
Anton
20-Jun-2005
[1351]
:)
DideC
20-Jun-2005
[1352]
No doc ? We even don't read the one we have ;-)
DideC
21-Jun-2005
[1353]
Q: is there something to flatten a block of block ?
ie: 
>>> probe a
=== [[1 toto] [2 "this is text" 5.63] [#as12 none]]
>>> magic-code! a
=== [1 toto 2 "this is text" 5.63 #as12 none]
Tomc
21-Jun-2005
[1354x2]
Yes this just came up again recently,
27 april  chat & parse
DideC
21-Jun-2005
[1356]
Thanks, didn't remember that
Pekr
23-Jun-2005
[1357x2]
how is find/match supposed to work on blocks? I thought following 
will work? 

find/match ["Petr Krenzelok"] "Petr"
what I have in mind is very simple kind of select, not needing to 
enter whole search key ...
Henrik
23-Jun-2005
[1359x3]
with blocks, I don't think that'll work with match, because it searches 
for the full element in a series, thus you need to search in two 
levels...
the block level and the string level
a find/deep would be very useful... recursive searching of blocks 
and objects. it could allow you to find a value in large objects 
and blocks quickly
Pekr
23-Jun-2005
[1362x2]
find/deep is long requested feature, but it was said as not being 
as trivial, as blocks can contain self-references etc ...
and what is find/only about?
Volker
23-Jun-2005
[1364x6]
with find/match you can check for abbreviations
>> find/match "Hello World" "W"    
== none
>> find/match "Hello World" "H"
== "ello World"
>> find/match ["Pekr" "Krenzelok"] "Pekr"
== ["Krenzelok"]
>> find/match ["Pekr" "Krenzelok"] "Krenzelok"
== none
/only is for this:
>> find ["Pekr" "Krenzelok" "asking"] ["Pekr" "Krenzelok"]
== ["Pekr" "Krenzelok" "asking"]
>> find/only ["Pekr" "Krenzelok" "asking"] ["Pekr" "Krenzelok"]
>> find/only [["Pekr" "Krenzelok"] "asking"] ["Pekr" "Krenzelok"]
== [["Pekr" "Krenzelok"] "asking"]
Ladislav
23-Jun-2005
[1370]
I wrote some functions of this kind, but anyway, what is "the shortest" 
reverse of:

    y: to integer! x: #{80000000}
Anton
23-Jun-2005
[1371x2]
Maybe this ?
>> reverse third make struct! [i [int]] reduce [y]
== #{80000000}
; quick testing looks good

>> foreach v [-1 0 1 1000 7777 2000000][print same? v to-integer 
reverse third make struct! [i [int]] reduce [v]]
true
true
true
true
true
true
Gabriele
23-Jun-2005
[1373x3]
hmm, a "short" way could be:
>> to binary! reduce [y / 16777216 y / 65536 y / 256 y]
== #{80000000}
btw, is this on rambo? i really think that to binary! should work 
with integers.
JaimeVargas
23-Jun-2005
[1376]
I second that.
Anton
23-Jun-2005
[1377x2]
I don't remember seeing that in rambo.
Doesn't appear to be there. I searched "binary!" and "binary"
Ladislav
23-Jun-2005
[1379]
submitted
Piotr
23-Jun-2005
[1380]
does anybody know why code below give me diffrent results? looks 
like get/set funcs operate on diffrent contexts:

ctx: context  [
  no-a: no-b: no-c: none
  set 'test does [
    foreach x [no-a no-b no-c] [set x "test-1"]
    foreach x [a b c] [set (to-word join "no-" x) "test-2"]

    foreach x [a b c] [print [join "no-" x get (to-word join "no-" x)]]
    foreach x [no-a no-b no-c] [print [x get x]]
  ]
]

test
probe no-a
probe ctx/no-a
Ladislav
23-Jun-2005
[1381]
to-word creates global words
Piotr
23-Jun-2005
[1382x2]
oops
then how construct local words?
Ladislav
23-Jun-2005
[1384x2]
bind to-word "no-b" 'no-a
(if 'no-a is local)
Piotr
23-Jun-2005
[1386]
so, fifth line (of example above) looks like:

foreach x [a b c] [
  d: to-word join "no-" x
  bind d 'no-a
  set d "test-2"
]

but his still does not work (for me)
Ladislav
23-Jun-2005
[1387]
ctx: context  [
  no-a: no-b: no-c: none
  set 'test does [
    foreach x [no-a no-b no-c] [set x "test-1"]
    foreach x [a b c] [
		d: bind to-word join "no-" x 'no-a
		set d "test-2"
	]

    foreach x [a b c] [print [join "no-" x get (to-word join "no-" x)]]
    foreach x [no-a no-b no-c] [print [x get x]]
  ]
]

test
probe no-a
probe ctx/no-a
Volker
23-Jun-2005
[1388]
i guess bind returns a new word here, but does not change the old? 
so it must be
d: bind d 'no-a