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

World: r3wp

[Core] Discuss core issues

Tomc
23-Apr-2010
[16452x2]
find/at  foo bar
== NaN
revolucent
30-Apr-2010
[16454x3]
How can I check that a given value conforms to a typeset? E.g.,  
If I say "make typeset! [string! integer!]" how can I check that 
the number 17 conforms to that typeset?
I've written a recursive function to do it, but I wondered if there 
weren't some better way.
Never mind. I just issued "source any-string?" and got my answer: 
find typeset type? :value. Perfect.
Gregg
3-May-2010
[16457x2]
On MIN/MAX with pairs, sorry I wasn't clear. I do NOT think it's 
a bug. I use that behavior myself, and seem to recall it being discussed 
long ago. It may not be what you expect initially, but I think it's 
the right design choice.
I just wanted to point it out in the context of pair comparisons.
Terry
7-May-2010
[16459x2]
how does one probe a map! ?
(probably an R3 question)
Maxim
7-May-2010
[16461x2]
>> probe a
make map! [
    r 4
]
== make map! [
    r 4
]

>> foreach [key value] a [print key]
r
>> a/e: 5
== 5

>> foreach [key value] a [print key]
r
e
I just tried the most obvious and it worked.
Steeve
7-May-2010
[16463]
>>foreach key a [print key]
works too.
Terry
7-May-2010
[16464]
how about this.. adding a variable as key in a map ie:
n: make map![]
b: 4398

n/b: "42" ; where b is 4398?
Steeve
7-May-2010
[16465x3]
n/:b:
n/:b:
n/:b:
Terry
7-May-2010
[16468]
ah ;)
Steeve
7-May-2010
[16469]
oups...
Terry
7-May-2010
[16470]
hmm... need a delimeter in the key.. 
n/8497:9823 ;err invalid time
n/9384-5842; err invalid date
Steeve
7-May-2010
[16471x6]
n/123x345
... doesn't work...
you could use an integer to store the 2 values (but each one limited 
to 2^32)
>> a: 1234
== 1234
>> b: 345
== 345

>> key: b or shift a 32
== 5299989643609
or you can make a string with the 2 parts and the delimiter as a 
key, but it will cost more memory
>> m/("123-456"): 45
== 45
Terry
7-May-2010
[16477x2]
there's no end of keys .. could use zero as the delim i suppose
what would the mem cost be to use strings?
Steeve
7-May-2010
[16479]
there's theory and reality, just make some tests using dp
Terry
7-May-2010
[16480]
dp? duck pond?
Steeve
7-May-2010
[16481]
? dp
Terry
7-May-2010
[16482]
dp.. your acronym.. what does it mean?
Henrik
7-May-2010
[16483]
? dp
Steeve
7-May-2010
[16484]
it's a function of R3
Terry
7-May-2010
[16485]
is it possible to search the value of map! without looping?
Steeve
7-May-2010
[16486]
well... take that memory problem aside for the moment , and go with 
string keys :)
Terry
7-May-2010
[16487]
wow
Steeve
7-May-2010
[16488]
ouch, don't think so...
Actually maybe your real key is the value and not the key.
Terry
7-May-2010
[16489x3]
that is REALLY fast
1,000,000 GETs  in 1.387 seconds
can't use the value as the key.. it could be 1GB
no matter.. can't search by value in Redis either.. i have a work 
around
Steeve
7-May-2010
[16492x2]
or create a second map! with reversed key-values
ok, you can't
Terry
7-May-2010
[16494x3]
I'm going to try more test.. but if this is accurate,  this would 
be nearly 10x faster than Redis
great.. there goes my weekend :(
thanks for your help
Henrik
7-May-2010
[16497]
small detail that may be useful:

>> series? make map! []
== false
BrianH
7-May-2010
[16498]
DP: :DELTA-PROFILE, meaning change in profile. It's R3's built-in 
profiler. R3 also has a built-in timer, DT: :DELTA-TIME.
Maxim
7-May-2010
[16499]
happy to have helped  :-)
BrianH
7-May-2010
[16500]
Terry, try FIND VALUES-OF map value, if you can afford to trade memory 
overhead for the loop.
Terry
7-May-2010
[16501]
can you return the key somehow?