AltME groups: search
Help · search scripts · search articles · search mailing listresults summary
world | hits |
r4wp | 5907 |
r3wp | 58701 |
total: | 64608 |
results window for this page: [start: 14301 end: 14400]
world-name: r3wp
Group: Core ... Discuss core issues [web-public] | ||
[unknown: 10]: 1-Apr-2005 | A nice one... | |
eFishAnt: 5-Apr-2005 | a nice 1x1... | |
JaimeVargas: 7-Apr-2005 | I hope this is useful for someone REBOL [] rest: func [s [series!]][skip s 1] define-object: func [ spec [block!] /local arg-spec ctx-spec object-name constructor-name predicate-name attributes spec-rule type-spec continue? w ][ arg-names: copy [] continue?: [none] ;used to stop parsing name-rule: [set w word! (insert tail arg-names w)] type-rule: [set w word! (unless datatype? attempt [get w] [continue?: [end skip]])] spec-rule: [name-rule some [name-rule opt [into [some [type-rule continue?]]]]] if any [ not parse spec spec-rule arg-names <> unique arg-names ][ make error! "invalid spec" ] object-name: to-string first arg-names constructor-name: to-word join 'make- object-name predicate-name: to-word join first arg-names '? attributes: rest arg-names arg-spec: copy [] foreach itm attributes [ insert tail arg-spec reduce [ to-word join itm '-value either block? w: select spec itm [w][[any-type!]] ] ] ctx-spec: copy [] arg-names: extract arg-spec 2 1 repeat i length? attributes [ insert tail ctx-spec reduce [to-set-word attributes/:i to-get-word arg-names/:i] ] ;create constructor function set constructor-name make function! compose [(reform ["Makes a new" uppercase object-name "object with attributes" mold attributes]) (arg-spec)] compose/only [make object! (ctx-spec)] ;body ;create predicate function set predicate-name make function! compose [(reform ["Determines if value is a" uppercase object-name "object"]) value [object!] /local types] compose/deep/only [ either (attributes) = rest first value [ foreach itm (attributes) [ unless any [ [any-type!] = types: select (arg-spec) to-word join itm '-value find types type?/word value/:itm ][return false] ] true ][ false ] ] ] | |
JaimeVargas: 7-Apr-2005 | Making a few modifications two define-method it will be possible to have multiple inheritance and object based dispatch in rebol. I need to think for a good name to post this in rebol.org. | |
JaimeVargas: 11-Apr-2005 | I had been teaching a few more tricks to DEFINE-METHOD. This is what it is capable off: | |
JaimeVargas: 11-Apr-2005 | ;define-method creates a "fingerprint" for each parameter-spec ;and evals corresponding code according to "fingerprint" define-method f [x: integer!] [x + 1] define-method f [s: block!] [attempt [pick s 2]] define-method f [x: decimal!] [sine x] >> f[1] == 2 >> f[[one two three]] == two >> b: [one two three] >> f[b] == two >> f[90.0] == 1.0 ;instrospection one can always see the methods of a function >> f-methods? [integer!] -> [x + 1] [block!] -> [attempt [pick s 2]] [decimal!] -> [sine x] ;singleton parameter specs are posible. ;This allows for "rule" based programming define-method fact [n: 0] [1] define-method fact [n: integer!][n * fact[n - 1]] >> fact-methods? [0] -> [1] [integer!] -> [n * fact [n - 1]] define-method fact-memoize [n: 0] [1] define-method fact-memoize [n: integer! /local r ][ r: n * fact[n - 1] define-method fact-memoize compose [n: (:n)] reduce [r] r ] >> time-it [fact[12]] == 0:00:00.000434 ;no memoization >> time-it [fact-memoize[12]] == 0:00:00.000583 ;first invoication >> time-it [fact-memoize[12]] == 0:00:00.000087 ;cache lookup ;dispatch for undefined type signals error >> fact[1.0] ** User Error: Don't have a method to handle: [decimal!] ** Near: fact [1.0] ;moization is more dramatic when calculating the fibonacci sequence define-method fib [n: 1] [1] define-method fib [n: 2] [1] define-method fib [n: integer!][ add fib[n - 2] fib[n - 1] ] define-method fib-memoize [n: 1] [1] define-method fib-memoize [n: 2] [1] define-method fib-memoize [n: integer! /local r][ r: add fib-memoize[n - 1] fib-memoize[n - 2] define-method fib-memoize compose [n: (:n)] reduce [r] r ] ;without memoization >> time-it [fib [20]] == 0:00:00.32601 >> time-it [fib [19]] == 0:00:00.207066 ;dramatic gains due to memoization >> time-it [fib-memoize[20]] == 0:00:00.002187 ;first invoication >> time-it [fib-memoize[20]] == 0:00:00.000096 ;cache lookup >> time-it [fib-memoize[19]] == 0:00:00.0001 ;cache lookup ;it is possible to overload some natives! define-method add [x: issue! y: issue!][join x y] add[1 1] == 2 add[1.0.0 1] == 2.1.1 add[#abc #def] == #abcdef | |
JaimeVargas: 11-Apr-2005 | It will be ther in a few minutes. | |
Sunanda: 12-Apr-2005 | Louis, I had a similar problem earlier this week. It might be a firewall issue: try system/schemes/ftp/passive: true In the case I looked at, it seems to be just cruft build-up.....Many things are not working on that machine, and FTP has now broken too. We "solved" the problem by installing SmartFTP -- it works every 2nd time you run it on that machine. | |
JaimeVargas: 12-Apr-2005 | ;; nexted-foreach a simple way of generating nexted foreach loops compose-foreach: func [var data code][reduce ['foreach var data code]] nexted-foreach: func [vars blocks code /local var][ if empty? blocks [return code] compose-foreach first vars first blocks nexted-foreach next vars next blocks code ] | |
JaimeVargas: 12-Apr-2005 | ;; it can be used like this do nexted-foreach [x y] [[1 2 3] [a b c]] [print [x y]] | |
Brock: 15-Apr-2005 | Is this a bug? 1) I read a directory on our ftp server and return a set of files of which 02 EN AR final.pdf is one of them 2) I then copy a URL address that returns a 404 indicating it couldn't find the file in question ie. http://www.cpcpension.com/files/2002EN AR final.pdf 3) I do a split-paths to-url on the contents of the clipboard:// that contains item in step 2) 4) I compare the file names for equality either using "=" or equal? and both return false 5) I check the type of each file, they are both 'file' types 6) I check the length of each file, the one from step 1) returns 20, step 2) returns 26 So, somewhere it is changing the representation of a space into the actual string " ". Any ideas? 6) | |
MichaelB: 15-Apr-2005 | Could someone just show me how to get the 'unset? function return true ?! Maybe I'm a bit stupid, but I simply don't get it working. Isn't really important, but should still work. e.g. unset 'a bl: [a] unset? 'a unset? first bl ????? shouldn't this return true ????? | |
Vincent: 15-Apr-2005 | MichaelB: unset? 'a <=> is the word 'a an unset! value -> no it's a word! value unset? first bl <=> is the first element of bl an unset! value -> no it's a word! value to know if a word as a value: value? 'word value? 'a == false but unset? () == true ; paren! are auto-evaluated, empty paren! -> unset! unset? print 2 == true ; 'print returns no value -> unset! unset? get/any 'a == true ; but as "a" is undefined, unset? a -> error! unset? unset 'a == true ; 'unset returns unset! 'unset? -> _value_'s datatype! = unset! unset! is for absence of value too: my-func [an-opt-arg [integer! unset!]][...] | |
Vincent: 15-Apr-2005 | Brock: 'to-url converts a string into an url without escaping, escaping is only done when showing the url string: to-url "http://www.cpcpension.com/files/2002EN AR final.pdf" ; works == http://www.cpcpension.com/files/2002EN AR final.pdf ; blanks -> to-url "http://www.cpcpension.com/files/2002EN AR final.pdf" ; don't works == http://www.cpcpension.com/files/2002EN AR final.pdf ; only looks the same, but contains "%" "2" "0" you can use 'do or 'load to interpret the string in clipboard: do read clipboard:// load read clipboard:// (same with 'to-file) | |
Brock: 20-Apr-2005 | I was thinking of adding a Cookbook entry along the following topic.... | |
Brock: 20-Apr-2005 | ; Sorting Unordered Key/Value Pairs ;unordered key/value pairs, keys in each record aren't in the same order data: [ [fld1 "c" fld2 "1" fld3 "b2"] [fld1 "b" fld3 "a1" fld2 "3"] [fld3 "c" fld2 "2" fld1 "a"] ] ; sorts on first text found, value is not sorted sort data ; notice reverse sort on first text found, value is not sorted sort/reverse data ; sort on value for fld1 key - ascending order sort/compare data func[a b] [a/fld1 < b/fld1] ; sort on value for fld1 key - descending order sort/compare data func[a b] [a/fld1 > b/fld1] ; sort on value for fld2 key - ascending order sort/compare data func[a b] [a/fld2 < b/fld2] ; sort on value for fld2 key - descending order sort/compare data func[a b] [a/fld2 > b/fld2] | |
Tomc: 20-Apr-2005 | when your compare func returns -1 0 1 instead of a bool you get stable sorts | |
Ammon: 20-Apr-2005 | Your /compare func is returning a boolean value because '< returns a boolean value. If you have it return -1 0 1 then you get a stable sort. | |
Brock: 21-Apr-2005 | Okay, I think I am following. If my parameters to the function were numbers, then using the [sign? a/1 - b/1] would provide a more accurate sort due to the tri-state return of the sign? function. However, since I am sorting strings and can AFAIK only compare using <>=, are you suggesting I should test all of the states and return 1,0,-1 as appropriate? | |
Brock: 21-Apr-2005 | ; is this what I am after for the compare function? [ if a/1 > b/1 [return 1] if a/1 = b/1 [return 0] if a/1 < b/1 [return -1] ] | |
Sunanda: 21-Apr-2005 | You got it!. And a little shorter, and maybe faster: [ if a/1 > b/1 [return 1] if a/1 < b/1 [return -1] return 0 ] Of course, you only need to worry about stable sorting if you have duplicate keys and need to retain the original entry sequence for them. Other wise [return a/1 < b/1] is fine and fast. | |
Alek_K: 26-Apr-2005 | I'm planning doing a database - in year it will be about 3000 records (30 fields each) What to use - some kind of rebol blocks (as here http://www.rebol.net/cookbook/recipes/0012.html ) or should I doing it with "mysql-protocol" by DocKimbel? | |
Claude: 26-Apr-2005 | i use rebol/command to connect a database (Iseries) by ODBC.. | |
Claude: 26-Apr-2005 | Alek_k, hi, i think there is already a little database name is DB.R | |
Claude: 26-Apr-2005 | wait a minute !!! a seek to it | |
Claude: 26-Apr-2005 | yes a have it, here is http://www.dobeash.com/it/rebdb/ | |
Claude: 26-Apr-2005 | hello, someone a idea for me please !! | |
sqlab: 27-Apr-2005 | Hi Claude, do you want to get the names of the columns? You do not get them by default. If you want just the names of the columns of a table, you should do like this insert stm ['columns "filexxx"] foreach column copy stm [probe column] look at sdk/doc/database.html#section-4.2 But beware, Rebol/Command does not support all datatypes, so maybe you will get some problems. Also depending how strict/relaxed your db system is "filexxx" should be written "FILEXXX" or as a fully qualified name. So better check with insert stm ['tables] what your db system expects. If you write a program, it is recommended, to name every column you want to get in your result set. Then you know the names too . | |
Micha: 28-Apr-2005 | how I use open / async harbour this after a dozen or so minutes application be closes | |
Sunanda: 2-May-2005 | Anyone got a better way of resetting all the values in block to a single initial value? Just curious, as the change/dup looks awkward --which usually suggests I've missed something: blk: [ 1 2 3 4 5 6 7 8 9] change/dup blk 0 length? blk | |
Sunanda: 2-May-2005 | On a related theme......Is there an easy/built-in way to check if all values in a series are equal? I'm using all-equal?: func [ser [series!]] [ser = join next ser first ser] As in: all-equal? [1 1 1 ] == true all-equal? "yyy" true all-equal? %xxx true | |
Micha: 4-May-2005 | whois: func [ host /local port ][ port: make port! join tcp:// [192.149.252.44 ":43" ] port/awake: func [ port /local ][data: copy port either data [ show data ] [ close port remove find system/ports/wait-list port ] halt] insert tail system/ports/wait-list port open/no-wait port insert port join "+" [ host "^/"] ] show: func [ d /local alpha ][ alpha: charset [#"A" - #"Z" #"a" - #"z"] d: find/tail d "City:" a: copy d a: find/tail a alpha a: copy/part a find a "^/" print [ "City: " a ] b: find/tail d "StateProv:" d: copy b b: find/tail b alpha b: copy/part b find b "^/" print [ "StateProv: " b ] c: find/tail d "Country:" c: find/tail c alpha c: copy/part c find c "^/" print [ "Country: " c ] ] whois 24.3.46.214 | |
Brock: 4-May-2005 | there is probably a better way to skip the variable number of spaces following the labels you are searching for, but haven't any experience with parse for this yet. With what I have provided you may be able to get the rest to work . I believe you can use 'any to skip multiple or no occurences of a parse rule | |
Brock: 4-May-2005 | show: func [ d /local alpha ][ get-city: [thru "City:" copy city to "^/"] get-stateprov: [thru "Stateprov:" copy stateprov to "^/"] get-country: [thru "country:" copy country to "^/" to end] parse d [get-city get-stateprov get-country] print [ "City: " a ] print [ "StateProv: " b ] print [ "Country: " c ] ] | |
Brock: 4-May-2005 | I WISH I WAS ABLE TO DELETE... I made a mistake <blush>, I forgot to remove your old variable names and there is a small error in the code I've posted above. | |
Brock: 4-May-2005 | ;here's a working show... but didn't easily come across a solution to allow for an unkown order of items to find show: func [ d /local alpha ][ get-city: [thru "City:" copy city to "^/"] get-stateprov: [thru "Stateprov:" copy stateprov to "^/"] get-country: [thru "country:" copy country to "^/"] parse d [get-city get-stateprov get-country to end] print [ "City:" tab trim city newline "Stateprov:" tab trim stateprov newline "Country:" tab trim country newline ] ] | |
MikeL: 5-May-2005 | Brock, A good example to look at for parsing is the make-doc script. Carl has updated with makedoc2.r available at this address http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=makedoc2.r but it is doing what your are asking about for the make doc source script which can have tags starting with === or --- followed by some text and a newline. The key is "rules: [some commands]" Have a look at it. | |
Gordon: 6-May-2005 | Hello; I'm wondering if there is a more efficeint way to assign values directly to a block of variables. My example involves reading lines from a file and assigning them one at a time to each variable. Here is the line format: LineFormat: [DateStr Manufacturer MF_Part TD_Part Desc Price1 Price2 Retail Stock Misc] Data: read/lines Filename Str: first Data Then I go though the String 'Str' and do the assigns DateStr: First Str Manufacturer: Second Str MF_Part: Third Str TD_Part: Fourth Str Desc: Fifth str Price1: skip Str 5 Price2: skip Str 6 Retail: skip Str 7 QOH: skip Str 8 Misc: skip Str 9 Am I missing something obvious about assigning one block of values to another block of variables? | |
Gordon: 6-May-2005 | Oops forgot a step; should be: Data: read/lines Filename DataStr: first data Str: parse/all DataStr none (the parse splits the lines of data into a block of values) | |
DideC: 6-May-2005 | a: [24 "Hello" 1.2.3] set [b c d] a print [d c b] | |
Gordon: 6-May-2005 | I'll give it a try. Thanks - BRB | |
Sunanda: 7-May-2005 | Any easy way of doing this? (I got a loop, but it feels there ought to be a more elegant way) a: "123123123" b: "12312345678" print skip-common a b "45678" ;; string after common part of both strings | |
Gordon: 7-May-2005 | Hello; How do you convert a letter (ASCII) to it's hex equivalent? I've tried to-hex but it wants an integer!? You would think it would be easier than: print to-integer to-string to-hex to-integer to-decimal to-char "a" which works but there has got to be an easier way. | |
Tomc: 7-May-2005 | >> to-hex to integer! #"A" == #00000041 | |
Sunanda: 7-May-2005 | Gordon, your method only works for chars than happen to map to decimals. Try this for an error: print to-integer to-string to-hex to-integer to-decimal to-char "M" Variant on Tom's to produce the same result as yours (may not work with 64-bit REBOL) form skip to-hex to-integer first "a" 6 | |
Tomc: 7-May-2005 | unfortinatly for me we dont have a 64 bit rebol | |
Gordon: 7-May-2005 | Nevermind. I think I should have used a copy of Writefile. DateStr must be a subset of WriteFile variable because of the reference to it's tail. | |
Gordon: 7-May-2005 | Yep, it just needed a copy as in: >> DateStr: skip tail copy WriteFile -10 == "2005-04-11" | |
Anton: 9-May-2005 | rot13: func [s [string!] /local result top][ result: copy s repeat n length? s [ top: either s/:n >= #"a" [97][65] ; determine upper or lowercase if (i: s/:n - top) < 26 [ ; only 26 letters in alphabet affected i: i + 13 // 26 ; perform rot13 poke result n to-char top + i ; insert new letter ] ] result ] | |
Gabriele: 9-May-2005 | >> index? find (as-binary a) xor as-binary b complement charset "^(00)" == 7 | |
Gabriele: 9-May-2005 | though, i'm not sure it's an easy way, and it is probably overkillif a and b are "big". | |
Gabriele: 9-May-2005 | >> parse a [any [(char: b/1) char (b: next b)]] == false >> b == "45678" | |
Janeks: 9-May-2005 | How to set correctly progress function for read-net? Or what causes following error and : >> myProgr: func [ tot bt ] [ print bt / tot ] >> read-net/progress to-url "http://maps.dnr.state.mn.us/cgi-bin/mapserv36?map=/usr/loca l/www/docs/mapserver_demos/tests36/expressions/test.map&map_counties_class_expression=(% 5bAREA%5d %3e 7577272785.15339)&layer=title&map_title_class_text=Counties+Larger+Tha n+Itasca+County&mode=map" :myProgr 0.425625 ** Script Error: not is missing its value argument ** Where: read-net ** Near: all [:callback size not callback size length? buffer data: true break] not data >> source read-net read-net: func [ {Read a file from the net (web). Update progress bar. Allow abort.} url [url!] /progress callback {Call func [total bytes] during transfer. Return true.} /local port buffer data size ][ vbug ['read-net url] if error? try [port: open/direct url] [return none] size: to-integer any [port/locals/headers/content-length 8000] buffer: make binary! size set-modes port/sub-port [lines: false binary: true no-wait: true] until [ if not data: wait [60 port/sub-port] [data: true break] if data: copy port/sub-port [append buffer data] all [:callback size not callback size length? buffer data: true break] not data ] close port if not data [buffer] ] >> | |
Gabriele: 9-May-2005 | is your callback function returning a value? i think it should return true normally, or false if you want to cancel the download. | |
Allen: 9-May-2005 | Use request-download as a guide. It has everything you need to know. you should be able to substitute read-thru with read-net if you wish. | |
Janeks: 10-May-2005 | O'k. My mistake are offen do not tell what is my target. So it is to get working status bar in a layout. As I understood it is possible by read-thru. | |
Janeks: 10-May-2005 | Thanks Gabriele. It was the reason. But to continue regarding status bar functions fired by read-thru. Than it is a problem just to kBox/image: read-thru/progress myUrl :myProgr . It is possible just by using local file i.e. kBox/image: read-thru/to/progress myUrl %tmpImg.png :myProgr | |
Janeks: 10-May-2005 | BTW: How to insert newline in a post? | |
Allen: 10-May-2005 | Janek. request-download has the example callback you need. View its source. here is a snippet. Where prog is the progressbar and stat is a label in your layout and stop is a value that controls that should be be set false outside of this func to start with, and can set to true via a cancel button to force a download to stop before completion. func [total bytes] [ prog/data: bytes / (max 1 total) stat/text: reform [bytes "bytes"] show [prog stat] not stop ] | |
Janeks: 11-May-2005 | Thanks Allen! The problem was so obvious that I did not think about it ;-) just it is impossible to know what size of image will be that is coming from a cgi process with many parameters. | |
Allen: 11-May-2005 | A easy job for REBOL... http://www.eyon.com/. I can't believe this tool needs to be 4mb zipped. | |
Volker: 12-May-2005 | i like this little function and cant find a good name. your: func [offset value] [ if value [value/:offset] ] usage: your 'facet get-style 'field its sometimes more readable IMHO than putting the interesting word far at the end of line. but i find no good name.. any suggestions? | |
RebolJohn: 12-May-2005 | Help peoples.. I have the following.. x: [a b c d] foreach y x [ set y make string! {} ] ;make them all empty strings. then I process/append info into the different groups a,b,c,d. Now, I want to write each string/list to a file of the same name. i.e. foreach y x [write to-file join y ".txt" ??GETVALUE?? y] Can someone clue me in on what I do at the ??GETVALUE?? position? Thanks peoples. | |
Anton: 12-May-2005 | Graham, try a different port, maybe it's port2 that is mapped in your system. | |
Group: Parse ... Discussion of PARSE dialect [web-public] | ||
Graham: 4-Nov-2005 | Rather than storing the HL7 result as free text, to store each sub test in a database. So, a Hb result will be stored as a Hb record. Another laboratory might call that "haemoglobin", so I need to map these two together. | |
BrianH: 4-Nov-2005 | Again, if you are just matching a single character or a fixed string, it is better and faster to just match it instead of matching a charset of that character. You don't need the caret, non-caret, pipe and nonpipe charsets you have above - the strings "^^" and "|" will do just as well. | |
Anton: 5-Nov-2005 | (and using a character instead of a string will save a tiny bit of memory too, I think) | |
Anton: 5-Nov-2005 | I have a strange issue of my own: | |
Anton: 5-Nov-2005 | var: 123 parse/all "a" [copy var "b" | (?? var)] ; ---> var: none var: 123 parse/all "a" [[copy var "b"] | (?? var)] ; ---> var: 123 var: 123 rule: [copy var "b"] parse/all "a" [rule | (?? var)] ; ---> var: 123 | |
Anton: 5-Nov-2005 | Yep, understand it now. It's like this: var: 1 parse "" [copy var "a" |] ;== true var ;== none | |
BrianH: 5-Nov-2005 | Anton, I used to use a character rather than a string too, because of the memory issue. But it turned out to be slower that way. I think parse only matches on strings, and single characters have to be converted to one-character strings before they can be passed to the matcher. At least that would explain the speed discrepancy. | |
Romano: 5-Nov-2005 | Anton, for me it is a wrong behaviour of parse. | |
Graham: 8-Nov-2005 | Perhaps I can get around that by instantiating a new hl7object with each MSH segment... | |
Anton: 15-Nov-2005 | Romano, I don't think it is an error anymore. Note my examples contain the pipe |, which allows the rule to succeed on none input. eg, these rules are equivalent: [copy var "a" | none] [copy var "a" | ] | |
Anton: 15-Nov-2005 | Your example, however, looks like an edge case... Probably parse checks for the end of the input before trying to match a string. | |
Henrik: 1-Dec-2005 | geomol, out of curiosity, have you tried those incidents where parse will lock up and you need to quit REBOL? Have you tried to keep it running for a few minutes and see what happens? | |
Henrik: 1-Dec-2005 | just wondering if that is a known behaviour. it returns to the console on its own | |
Henrik: 1-Dec-2005 | wondering if there is some sanity limit on a billion loops or something | |
Geomol: 1-Dec-2005 | Anyway, parse works in a certain (and you could say special) way, when dealing with strings: >> parse "a" [char!] == false >> parse "a" [string!] == false >> parse "a" [#"a"] == true >> parse "a" ["a"] == true | |
Geomol: 1-Dec-2005 | So parsing a string for [any string!] maybe doesn't make much sense. | |
Geomol: 1-Dec-2005 | And parsing strings and chars within blocks give more meaning, when looking for datatypes: >> parse ["a"] [char!] == false >> parse ["a"] [string!] == true >> parse [#"a"] [string!] == false >> parse [#"a"] [char!] == true | |
Henrik: 1-Dec-2005 | using datatypes as rules, I think only work with blocks, not strings, which is why it returns false in the first two cases with "a" | |
Geomol: 1-Dec-2005 | You can with a little trick: >> no-chars: complement charset "ab" == make bitset! #{ FFFFFFFFFFFFFFFFFFFFFFFFF9FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF } >> parse "1234ab" [some no-chars mk: (print mk) to end] ab == true | |
Anton: 2-Dec-2005 | I seem to remember Carl S. saying something about adding a safety check to parse to jump out of infinite loops... | |
Geomol: 2-Jan-2006 | It's not a good example. You could do something like: >> parse {<H1>A heading</H1>} [copy heading ["<H" ["1" | "2" | "3"] ">" to "</"]] == false >> heading == "<H1>A heading" | |
Henrik: 8-Jan-2006 | yeah, each rule stop at a position, not going past it. that way you wouldn't be able to reach the tail of the series. THRU will get you to the tale | |
Ammon: 8-Jan-2006 | The problem wasn't really that I wasn't so much not hitting the end as it was figuring out how to keep all of my data. I'm breaking up some text using a semi-dynamic set of recursive rules and I kept loosing my last bit of data or hanging the interpreter... | |
Anton: 8-Jan-2006 | Ah, recursive rules. :) I pushed my variables onto a stack when recursing, then popped them off when returning. That tends to bloat the code a fair bit. ( push-vars [a b c] recursive-rule pop-vars [a b c] ) so then you get to thinking to generate this code automatically with a make-recursive-rule function, which takes a parse rule, looks for recursion in it, then surrounds it with push-vars and pop-vars for you (kind of macro expansion). Or I did something like that, anyway. | |
Anton: 8-Jan-2006 | http://www.lexicon.net/antonr/rebol/library/make-recursive-rule.r (Mmm.. it says it has a big flaw, but I know I'm using it successfully in a program. Maybe my input never trips the flaw, or I fixed it and forgot to write that down... Anyway, it gives you an idea how the user interface can look.) | |
Henrik: 12-Jan-2006 | I always hear that if you need to use a UNIX OS, you need to learn them. So far I've done fairly well without them, but have been configuring procmail once, which was a complete nightmare. :-) | |
Sunanda: 12-Jan-2006 | It'd be fun to compare parse and REs..... Maybe a shootout between experts in both. Both sides could learn a lot. | |
Gregg: 12-Jan-2006 | There was some talk about that on the ML a few years back. Joel and Ladislav had some great exchanges IIRC. Parse and RegEx are different tools. I can see the power of RegExs, but they aren't for the faint of heart when you start doing complex things. A RegEx can be very concise, and can be very handy for simple pattern matching. | |
Oldes: 1-Mar-2006 | you cannot use this in a dialect! | |
Oldes: 1-Mar-2006 | and I'm not such a poor:-) I am using double parenthesis in my dialect instead of using commas (it's ugly, but it's working) | |
Oldes: 1-Mar-2006 | I still think it's a shame, that we cannot load strings with commas, so we cannot forexample parse javascript or actionscript | |
Oldes: 1-Mar-2006 | my code looks like doSomeFunction(("a" add b) 1) | |
Oldes: 1-Mar-2006 | in actionscript it's doSomeFunction("a" add b, 1) | |
Volker: 1-Mar-2006 | doSomeFunction("a" add b # 1) doSomeFunction("a" add b . 1) ? | |
Volker: 1-Mar-2006 | But chars like # are easier to search/replace. But i dont defend my solution, yours looks ok. Do you write your dialect-code in rebol-blocks or in a string? | |
Anton: 5-Mar-2006 | What you did was consume the five numbers, then try to set val to a sixth one. |
14301 / 64608 | 1 | 2 | 3 | 4 | 5 | ... | 142 | 143 | [144] | 145 | 146 | ... | 643 | 644 | 645 | 646 | 647 |