World: r3wp
[Core] Discuss core issues
older newer | first last |
Sunanda 28-Mar-2006 [3861] | . [apologies for dotting, but I can see from rebol.net that I'm not synced in this group] |
[unknown: 10] 28-Mar-2006 [3862x3] | What is the quickest routine in rebol to compare 2 series of values based on position of the value against data of the value.. i.e. a: [ 1 2 3 4 5 ] b:[ 5 6 7 8 9 ] |
Mmm how do i exmaplain this correctly... ;-) | |
How do i check If a value in serie a does occeur in b on a specific position ? Currently im doing that with a foreach including a for loop..But somehow rebol should have something buildin i thought? or not.. unqiue intersect and difference are not good enough for this...and speed is a concern too.. | |
DideC 28-Mar-2006 [3865x2] | an exemple? |
an example? | |
Allen 28-Mar-2006 [3867] | Rebolinth: Need you to show an example with the expected results. Also are A and B of fixed length or varied? |
Gregg 29-Mar-2006 [3868] | Use FIND + INDEX? maybe? |
[unknown: 10] 29-Mar-2006 [3869x2] | yes well find and index where not what i searched for...ill drop an example...hold on a few hours ;-) back ltr... |
...an example... I build in lisp a latin-square example and rebuil it in rebol.. the bottle neck is not the random generator but its for me the function called 'clean? (can this function be exchanged with a rebol buildin funtion? or even be made smaler?) ; a latin square in rebol random/seed now clean?: func [ x /local bb i ][ catch [ foreach bb b [for i 1 9 1 [ if = pick bb i pick x i [throw false] true ]]]] print "---- running ----" T1: now/time/precise insert/only b: copy [] random/seed [ 1 2 3 4 5 6 7 8 9 ] print first b while [ < length? b 9 ][ if clean? set 'x random [ 1 2 3 4 5 6 7 8 9 ] [ print x insert/only b x ]] print rejoin [ "Timed: " now/time/precise - T1 ] wait 0:0:5 quit | |
Allen 29-Mar-2006 [3871] | As a general rule, try to use native! looping functions, they are faster. In the above the native! "repeat" could replace the use of "for" |
[unknown: 10] 30-Mar-2006 [3872] | talking about speed improvement!! that 'for loop is very slow compaired to the 'repeat ;-) thanks.. |
DideC 30-Mar-2006 [3873] | ; Try : source for source repeat ; and see !!! |
Oldes 1-Apr-2006 [3874x2] | Is there someone using a Rebol script to send IF_MODIFIED_SINCE in HTTP get header? |
ech, I forgot I can use read/custom to set the header easily:-) read/custom page [header [If-Modified-Since: "Sat, 1 Apr 2006 14:42:13 GMT"]] | |
Anton 1-Apr-2006 [3876] | :) |
Thør 1-Apr-2006 [3877] | . |
Thør 2-Apr-2006 [3878] | , |
Anton 2-Apr-2006 [3879x2] | Greetings Thør. |
Ok I have a question. I would like to catch an error inside a function and throw it out so the error position is reported "near" the function itself. As far as I understand we should do that with something like this: check: func [ [catch] ; <-- function spec attribute flag which changes the reported position of the error. ][ load "http://(" ; <-- cause an error on purpose ] Now I have tried various things: >> check: func [][load "http://("] >> check ** Syntax Error: Missing ) at end-of-script ** Near: (line 1) http://( >> check: func [[catch]][load "http://("] >> check ** Syntax Error: Missing ) at end-of-script ** Near: (line 1) http://( >> check: func [[catch]][throw-on-error [load "http://("]] >> check ** Syntax Error: Missing ) at end-of-script ** Near: But none of these seems to be reporting the "Near:" position that I'm expecting. (Indeed, the last one looks kind of buggy reporting to me. Anyone?) | |
Volker 2-Apr-2006 [3881x5] | >> check: func [][throw-on-error[load "http://("]] >> check ** Throw Error: ** Syntax Error: Missing ) at end-of-script ** Near: (line 1) http://( > |
You need to throw the error for [catch] to see it | |
Hmm, that looks like one of your tries. | |
; usually works like this >> check: func [[catch]][throw-on-error[1 / 0]] check2: does[check] check2 ** Math Error: Attempt to divide by zero ** Where: throw-on-error ** Near: check >> check: func [[catch]][1 / 0] check2: does[check] check2 ** Math Error: Attempt to divide by zero ** Where: check ** Near: 1 / 0 | |
;but load seems really to confuse the near: >> check: func [[catch]][throw-on-error[load "("]] check2: does[check] check2 ** Syntax Error: Missing ) at end-of-script ** Near: | |
Anton 2-Apr-2006 [3886x2] | Yes, that's just what I was thinking.. It seems most likely that LOAD confused the interpreter about the "Near:" position. |
So it looks like a bug to you too ? I would like to check with Ladislav, Romano or Gabriele. | |
Ladislav 3-Apr-2006 [3888] | I suggest you to put it to RAMBO |
Anton 3-Apr-2006 [3889] | Ok, submitted. |
Thør 4-Apr-2006 [3890] | manual resync |
Jerry 5-Apr-2006 [3891] | Outer: context [ name: "Outer" Inner: context [ name: "Innter" get-outer-name: does [ ; I would like to return the outer name. ; How would I do that? Thank you. ] ] ] ; Making the get-outer-name function return Outer/name is not ; a good idea, since Outer can be cloned and its name can be ; changed, as follows Outer2: make Outer [ name: "Outer2"] Outer2/Inner/get-outer-name ; Any help will be appreciated. |
Sunanda 5-Apr-2006 [3892] | As you say, the context doesn't have a name. it could be anonymous, or multiple words could be assigned to it, so there is no one "name" outer2: :outer outer3: :outer2 |
Anton 5-Apr-2006 [3893x3] | You have to maintain a parent attribute. >> outer: context [inner: context compose [parent: (self)]] >> probe outer/inner/parent make object! [ inner: make object! [ parent: make object! [...] ] ] |
It works by composing the block before making it into an object. So self at that moment evaluates to the outer object. | |
When cloning the outer object, you will have to make sure to also clone the inner object (ie. you must implement deep recursive clone yourself), making sure to maintain parent correctly. | |
Jerry 5-Apr-2006 [3896] | Thanks. Anton and Sunanda. |
JeffM 8-Apr-2006 [3897x2] | Is there any way to get the RGB data from a loaded image? |
I assume there is a simple refinement to do so (like /size to get the size of the image), but I can't seem to find it. | |
Gabriele 8-Apr-2006 [3899] | >> logo.gif == make image! [100x24 #{ 252525141414141414141414141414141414141414141414141414141414 14141414141414141414141414141414141414141414... >> logo.gif/rgb == #{ 2525251414141414141414141414141414141414141414141414141414141414 141414141414141414141414141414141414141414141414141414141414... >> logo.gif/alpha == #{ 0000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000... |
JeffM 8-Apr-2006 [3900] | thanks! exactly what i needed :-) |
james_nak 8-Apr-2006 [3901] | I was curious what the "/only " refers to. I know what it does but does anyone have an idea of the reasoning behind the wording? It's been one of those things that has bugged me. :- ) |
JeffM 8-Apr-2006 [3902] | i always assumed it meant "only the top level" (as in not recursive) |
[unknown: 9] 9-Apr-2006 [3903] | KEY123 (ignore this please) |
JeffM 10-Apr-2006 [3904x3] | Can REBOL/SDK define functions that will be called from C and passed to a C function? For example: |
c-logger: make routine! [ "Define the callback function for error tracking." logger: [string!] "using string! since a function ptr is just a pointer" return: [integer!] ] my-lib "C_Logger" rebol-logger: func [s] [ print s ] c-logger :rebol-logger | |
also, sorry, i probably shoudl have posted this into the SDK group -- still getting used to AltMe | |
Jerry 10-Apr-2006 [3907] | How can I convert an integer! value to 2-byte hex binary! value? Say, >> do-something 15 == #{000F} Thanks. |
Graham 10-Apr-2006 [3908] | >> to-hex 15 == #0000000F |
Pekr 10-Apr-2006 [3909] | to-binary [15] |
Sunanda 10-Apr-2006 [3910] | Though that method, Petr, is awkward for values above 255: to-binary [1234] == #{D2} ;; not the obvious result! to-binary [12 34] ;; need to separate out the bytes == #{0C22} ;; each octet is converted separately, so may still not be what was expected. |
older newer | first last |