World: r3wp
[Core] Discuss core issues
older newer | first last |
Henrik 26-Aug-2010 [18033x2] | looks like a bug to me. |
also in R3. both are mezzanines, so it should be possible to fix it. | |
BrianH 26-Aug-2010 [18035x2] | It's a bug. Scheduled to be fixed in 2.7.8 - fix already submitted, and in R2/Forward. Submitted for R3 as well. |
I can post the fixed versions here as well if you like. | |
Will 26-Aug-2010 [18037x2] | Thank you, do you have a link where I can get the pathced version ? |
Oh, yes please, but I would still be interested in where I can get your latest R2/Forward 8-) | |
BrianH 26-Aug-2010 [18039] | It's where all the mezzanine source and fixes go: R3 chat, aka DevBase. |
Will 26-Aug-2010 [18040] | humm ok I'll check how to browse R3 chat later, Now if you could paste a copy of extract here I would be very thankfull 8-) |
BrianH 26-Aug-2010 [18041x2] | R3 mezzanines are in #26. R2 mezzanines are in #41. R2/Forward is in #837. |
Here's the R2 version: extract: func [ "Extracts a value from a series at regular intervals." [catch] series [series!] width [integer!] "Size of each entry (the skip)" /index "Extract from an offset position" pos "The position" [number! logic! block!] /default "Use a default value instead of none" value "The value to use (will be called each time if a function)" /into "Insert into a buffer instead (returns position after insert)" output [series!] "The buffer series (modified)" /local len val ][ if zero? width [return any [output make series 0]] ; To avoid an infinite loop len: either positive? width [ ; Length to preallocate divide length? series width ; Forward loop, use length ][ divide index? series negate width ; Backward loop, use position ] unless index [pos: 1] either block? pos [ if empty? pos [return any [output make series 0]] ; Shortcut return parse pos [some [number! | logic! | set pos skip ( throw-error 'script 'expect-set reduce [[number! logic!] type? get/any 'pos] )]] unless into [output: make series len * length? pos] if all [not default any-string? output] [value: copy ""] ; R2 PARSE doesn't work well for binary!, so spoof a string!. if binary? series [series: as-string series] forskip series width [forall pos [ if none? set/any 'val pick series pos/1 [set/any 'val value] output: insert/only output get/any 'val ]] ][ unless into [output: make series len] if all [not default any-string? output] [value: copy ""] ; R2 PARSE doesn't work well for binary!, so spoof a string!. if binary? series [series: as-string series] forskip series width [ if none? set/any 'val pick series pos [set/any 'val value] output: insert/only output get/any 'val ] ] either into [output] [head output] ] | |
Will 26-Aug-2010 [18043] | THANK YOU! 8-) |
BrianH 26-Aug-2010 [18044x5] | Here's the R3 version: extract: func [ "Extracts a value from a series at regular intervals." series [series!] width [integer!] "Size of each entry (the skip)" /index "Extract from an offset position" pos "The position(s)" [number! logic! block!] /default "Use a default value instead of none" value "The value to use (will be called each time if a function)" /into "Insert into a buffer instead (returns position after insert)" output [series!] "The buffer series (modified)" /local len val ][ ; Default value is "" for any-string! output if zero? width [return any [output make series 0]] ; To avoid an infinite loop len: either positive? width [ ; Length to preallocate divide length? series width ; Forward loop, use length ][ divide index? series negate width ; Backward loop, use position ] unless index [pos: 1] either block? pos [ unless parse pos [some [number! | logic!]] [cause-error 'Script 'invalid-arg reduce [pos]] unless output [output: make series len * length? pos] if all [not default any-string? output] [value: copy ""] forskip series width [forall pos [ if none? set/any 'val pick series pos/1 [set/any 'val value] output: insert/only output :val ]] ][ unless output [output: make series len] if all [not default any-string? output] [value: copy ""] forskip series width [ if none? set/any 'val pick series pos [set/any 'val value] output: insert/only output :val ] ] either into [output] [head output] ] |
If you aren't using 2.7.7 the THROW-ERROR in the block pos checking won't work, since earlier versions don't have that function. | |
It's mezzanine too though. Let me know if you need it. | |
This bit in the R2 version (twice): ; R2 PARSE doesn't work well for binary!, so spoof a string!. if binary? series [series: as-string series] is I think left over from trying to optimize away the FORSKIP and FORALL from the R2 version using PARSE. That approach was rejected a couple years ago, so those lines could be removed in theory. FORALL and FORSKIP are native in R3, as all loop functions must be for now. | |
Never mind, it is just the comments that are wrong. The AS-STRING is legit, but related to the general design flaws in R2's binaries that are fixed in R3. | |
Graham 27-Aug-2010 [18049] | >> within? 0x0 0x0 2x2 == true >> within? 0x0 0x0 0x0 == false |
Anton 27-Aug-2010 [18050x3] | It's a zero sized box, right? |
No point can be in a zero sized box. | |
So those results look fine to me. | |
Graham 27-Aug-2010 [18053x3] | the 0x0 point occupies all points of the box simultaneously :) |
methinks that within? should take, integers, pairs and triplets so integers for a one dimension, pairs for two dimensions and triplets for 3D | |
and maybe take an optional function if you want to supply a sphere or other volume | |
BrianH 27-Aug-2010 [18056x3] | We don't have triplets. And the source of within is simple enough (on purpose, because of performance issues) that any optional function should be separate. |
Anton, points have zero size. A zero-size rectangle could contain in theory one point. The question is whether WITHIN? is inclusive of that last point or not. | |
However, WITHIN? isn't for points, it's for pixels, and pixels have area. Which is I guess why that point isn't included. | |
Graham 27-Aug-2010 [18059] | tuple |
Henrik 28-Aug-2010 [18060] | tuple is 8-bit only. I think WITHIN? looks ok. |
Graham 28-Aug-2010 [18061] | triplets then! |
Anton 28-Aug-2010 [18062] | (sorry, I did actually mean pixel) |
BrianH 28-Aug-2010 [18063] | (I figured as much, but felt that the distinction was worth mentioning) |
Gabriele 30-Aug-2010 [18064] | Should this be considered a bug? (R2) >> b: reduce [:print :insert :read :+] == [native action native op] >> find b :print == none >> find b :insert == [action native op] >> find b :+ == [op] >> find b :read == none >> :print = :print == true >> :print = :read == false |
Anton 30-Aug-2010 [18065x2] | So FIND cannot locate native! types by direct comparison. Looks like a bug to me ! I confirm the above behaviour with my testing on View 2.7.6.4.2 on Linux. |
(FIND can locate native! datatypes, however, so that's working ok.) >> find b native! == [native action native op] >> find next b native! == [native op] | |
elenay 30-Aug-2010 [18067x3] | FAST ? |
k: enbase checksum/secure to-string now/precise | |
k: enbase checksum/secure to-string now/precise k': enbase checksum/secure to-string now/precise Give same return !!! better include wait .1 between ! | |
Sunanda 30-Aug-2010 [18070] | A useful warning not to use current time as a unique key :-) A wait of .001 is sufficient to get me different times -- but that may be processor and operating system dependent. This code may help in exploring your limits: n: 0 forever [ n: n + 1 k: enbase checksum/secure to-string now/precise wait .001 k': enbase checksum/secure to-string now/precise if k = k' [print n halt] ] |
elenay 30-Aug-2010 [18071] | better hint fo a unique key ? (meet rebol a week ago) |
Henrik 30-Aug-2010 [18072x2] | Never use current time as key generator. Win98 uses about 0.01 second timer resolution, which slapped me in the face a few years ago. Other OS'es may be similar. |
elenay, should be enough to apply random to the binary. | |
elenay 30-Aug-2010 [18074] | true, clever, but we never knows. don't you ? I do :-) |
Sunanda 30-Aug-2010 [18075] | As Henrik says, this code _probably_ returns unique ids: n: 0 forever [ n: n + 1 k: random/secure enbase checksum/secure to-string now/precise k': random/secure enbase checksum/secure to-string now/precise if k = k' [print n halt] ] But for best results, add in something more: -- a count? -- user name / IP address? |
Henrik 30-Aug-2010 [18076] | a count would be useful |
Steeve 30-Aug-2010 [18077] | join the previous k |
elenay 30-Aug-2010 [18078] | n reach 2 000 000, did not halt by itself. I take it like this, with mentions for responsability should be directed to you Sunanda ;-) Thanks |
Sunanda 30-Aug-2010 [18079x3] | That leaves you three basic options:) |
That leaves you three basic options:) | |
(opps -- my enter key got reset somehow) 1. hire me at a reasonable rate as your official scapegoat 2. make yourself potentially a billion times safer (so no need for a scapegoat) by adding something to the checksum string -- eg: k: rejoin [random/secure enbase checksum/secure to-string now/precise random/secure 100'000'000] 3. read up on UUID / GUID generation, eg: http://www.rebol.org/ml-display-thread.r?m=rmlCYYK | |
Maxim 30-Aug-2010 [18082] | sunanda, for your timing issue in generating unique keys, use my precise time module it NEVER returns the same time twice, the counter is CPu based. |
older newer | first last |