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

World: r3wp

[Core] Discuss core issues

Terry
7-May-2010
[16501x2]
can you return the key somehow?
after some testing strings as keys and values are the way to go.. 
slightly faster ( to-binary? overhead?) and when you write the db 
to file, the strings are half the size
Graham
9-May-2010
[16503]
How does one sort on the 3 item in a seres?
Henrik
9-May-2010
[16504]
example?
BrianH
9-May-2010
[16505]
Use SORT/compare with an integer argument for the index of the records 
you want compared, and don't forget /skip for the record length. 
Like this:
>> sort/skip/compare [1 5 2 4 3 3 4 2 5 1] 2 2
== [5 1 4 2 3 3 2 4 1 5]
Sunanda
9-May-2010
[16506x2]
You mean using /skip and /compare to sort a series in sets?
s: [1 2 8 a   1 2 6 b   1 2 7 c]    ;; three sets of four items
sort/skip/compare s 4 [3]        ;; sort on the third item
== [1 2 6 b 1 2 7 c 1 2 8 a]
oops --- Brian just beat me to it!
Graham
9-May-2010
[16508]
thanks .. can someone update the docs http://www.rebol.com/docs/words/wsort.html
BrianH
9-May-2010
[16509]
Didn't know you could put the /compare index in a block. Can you 
specify more than one index?
Sunanda
9-May-2010
[16510]
Yes you can:
sort/skip/compare s 4 [1 2 4 3]
== [1 2 8 a 1 2 6 b 1 2 7 c]
BrianH
9-May-2010
[16511]
Graham, no, noone can update that doc page, it's a permissions issue. 
All docs updates by anyone other than Carl are on hold.
Graham
9-May-2010
[16512x2]
someone = Carl
:)
BrianH
9-May-2010
[16514x2]
Ask in chat or CureCode, Carl won't see the request here.
It's best to ask in CureCode anyways, because the request will stay 
there where we can find it until the issue is fixed.
Graham
9-May-2010
[16516]
some of the browsers allow you to annotate the page so I can see 
my own notes
BrianH
9-May-2010
[16517]
But the people who would fix the docs won't see your notes.
Graham
9-May-2010
[16518x2]
But at least I will ...
And when we get the permissions to do so, we can then
BrianH
9-May-2010
[16520]
OK, good, that way you will remember to submit a CureCode ticket 
later.
Henrik
9-May-2010
[16521x2]
>> a: 0.24.26
== 0.24.26
>> poke a 2 155
== 0.155.26
>> a
== 0.24.26 ; huh?
fixed in R3 though.
Ladislav
9-May-2010
[16523x7]
>> a: b: 0.24.26
== 0.24.26

>> poke a 2 155

** Script error: poke does not allow tuple! for its value argument
if you consider that fixed, then I do agree with you
nevertheless, the behaviour in R2 looks reasonable too
(taking into account, that tuples are immutable)
re "ask in chat or CC" - I asked in chat, privately, but do not see 
any reaction yet, and I added a comment to CC #1571
also: http://eupat.ffii.org/
sorry, misplaced post
Henrik
9-May-2010
[16530]
since tuple are not series in R3, then I'd say it's fixed.
Maxim
10-May-2010
[16531]
tuple aren't immutable in R2 OR R3

>> a: 1.2.34
== 1.2.34
>> a/2: 33
== 33
>> a
== 1.33.34

this works in both R2 and R3
Steeve
10-May-2010
[16532]
nope, they are

>> a: b: 1.2.3
== 1.2.3
>> a/1: 33
== 33
>> a
== 33.2.3
>> b
== 1.2.3
Maxim
10-May-2010
[16533x2]
ok... yeah in that sense.
they aren't series.
Ladislav
10-May-2010
[16535]
tuple aren't immutable in R2 OR R3

 - it is discussed in http://www.rebol.net/wiki/Identity#Expressions_modifying_their_values

Tuples are exactly as mutable as integers in R2 as well as in R3
amacleod
11-May-2010
[16536x2]
BrainH asked: Didn't know you could put the /compare index in a block. 
Can you specify more than one index?

Sunanda says: Yes you can:
sort/skip/compare s 4 [1 2 4 3]
== [1 2 8 a 1 2 6 b 1 2 7 c]


That's great but can you do that with a block of blocks of  data....

example: 
s: [
	[1 2 8 a]
	[1 2 6 b] 
	[1 2 7 c]]
]
remove extra ]
Maxim
11-May-2010
[16538]
use a compare function for that
amacleod
11-May-2010
[16539]
So nothing as easy as Sunanda's example built into rebol?
Sunanda
11-May-2010
[16540x2]
To turn Maxim's comment into an example:

   sort/compare s func [a b] [
== [
    [1 2 6 b]
    [1 2 7 c]
    [1 2 8 a]
]
s
Oops that SORT line should be
   sort/compare s func [a b] [return a/3 < b/3]
Maxim
11-May-2010
[16542]
thanks... I was a bit lazy there  ;-)
amacleod
11-May-2010
[16543]
so something like this will give me a sort on multi indexes?
sort/compare s func [a b] [return a/4 < b/4 return a2 < b/2]
Maxim
11-May-2010
[16544x4]
btw return is never required at the end of a func .. and slows down 
rebol A LOT in tight loops.
amacleod... your example would stop at first compare (you're returning 
right away)
try this instead:

sort/compare s func [a b] [
	either  a/4 = b/4  [
		a2 < b/2
	][
		a/4 < b/4
	]
]
but not exactly sure of results...
Sunanda
11-May-2010
[16548]
For safe stable, sorting return -1, 0, +1 rather than true or false:
   http://www.rebol.com/docs/changes-2-5.html#section-72
amacleod
11-May-2010
[16549x2]
I do not know if that is what I want...i'm looking to prioritize 
each compare giving each a "weight"
example" 


sorting a list of first and last names first on last then on first 
in case of same last names