World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
Geomol 20-Feb-2008 [1346] | You can with my RebXML found here: http://home.tiscali.dk/john.niclasen/rebxml/ The script xml2rebxml.r read an XML structure into a block with content defined in the spec: http://home.tiscali.dk/john.niclasen/rebxml/rebxml-spec.html |
btiffin 20-Feb-2008 [1347] | Kinda ... out of the box XML is not 100% but load/markup may do what you want for some cases If that is not sufficient, some rebols have written extensions. Umm, like John just posted. :) |
SteveT 20-Feb-2008 [1348] | That's great thank's guys ! |
Geomol 20-Feb-2008 [1349] | You're welcome! |
Sunanda 20-Feb-2008 [1350] | 'parse-xml is a standard REBOL function in 'core that does some basic XML processing. It may be enough for you. I use Gavin's XML-parse functions every day: http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=xml-parse.r Not tried John's yet :-) |
SteveT 20-Feb-2008 [1351] | Thanks Sunanda |
Geomol 20-Feb-2008 [1352] | REBOL is quite useful for web-applications and handling data and technologies born from the internet-boom in the computing world. I bet, there are many REBOL-based solutions out there. |
Gregg 20-Feb-2008 [1353] | PARSE-XML is a built-in func as well. Not as complete as Gavin's, but works well for basic things. The biggest mod I've made to it is to swap the order of element value and attributes in the resulting block. That way you can address the value using path notation or SELECT. Working with attributes takes a little more work. |
Rod 20-Feb-2008 [1354] | So for anyone new to REBOL or more generally to Forth (being one of the inspirations behind REBOL) I'd like to strongly recommend reading Leo Brodie's Thinking Forth - free PDF here - http://thinking-forth.sourceforge.net/ I stumbled across this group of programming books http://prog21.dadgum.com/19.html and it reminded me I had meant to do some reading on Forth. I'm now a third of the way through the Thinking Forth book kicking myself for not having dug into this earlier. Just like learning about the functional perspective with Lisp and Erlang this reading is expanding my programming perspective with every chapter. In addition to being valuable in the REBOL context it is simply a great book on programming in any context. |
btiffin 20-Feb-2008 [1355x2] | Rod. Classic. Not as classic as Starting Forth, but hey. Marcel Hendrix has posted Starting Forth as well, but had trouble with the cartoons, and the replacements are not quite as "fun". And just so ya know, only Marcel was given the right to copy, explicity only Marcel, by Forth Inc. http://home.iae.nl/users/mhx/sf.html |
Whoa. Elizabeth has posted a much nicer reprint on the forth.com site. http://www.forth.com/starting-forth/ Nice! | |
Rod 20-Feb-2008 [1357] | Thanks Brian, will check out starting forth as well. |
btiffin 20-Feb-2008 [1358] | Most of had Starting Forth and Thinking Forth so our bosses bought us great huge fat Thesauri thinking it would make us better coders. We laughed at first, then our dictionary grew to the 100,000 word mark and they started to get dog eared. :) |
Rod 20-Feb-2008 [1359] | Hah, I can already appreciate that view, even with just a little reading and applying it to some work concepts I found the desire for words exploading! |
btiffin 20-Feb-2008 [1360] | Yeah; I think I was on my ninth or tenth version of "READ" when I started going with foreign languages. And being forthers, you wouldn't want to write TROUBLE-REPORT over and over again, so we got used to TRP and FLD and got really good at pronouncing just about any random collection of letters. TERP and FLUD (field) for the former. It's why I don't use the expression SeQueL It's SQEEL! :) Ahh, fun with words. |
JohanAR 3-Mar-2008 [1361] | I have this reduce statement, that's supposed to form a block for later processing. Now I want to include in that a switch to add some more stuff if a variable is not none. However it seems like the if-statement returns a none which gets included in the result block :( block: reduce [ 'aword "blah blah" if var [ 'avariable var ] ] |
Henrik 3-Mar-2008 [1362x4] | block: reduce ['aword "blahblah" either var [['avariable var]][[]]] |
seems to include the rest as a block | |
better one: block: compose ['aword "blahblah" (if var [['avariable var]])] | |
remember the extra block inside the if statement, otherwise only 'var will be returned from it | |
JohanAR 3-Mar-2008 [1366] | I still seem to get a none in the block if the varable isn't available |
Henrik 3-Mar-2008 [1367] | block: compose ['aword "blahblah" (either var [['avariable var]][[]])] |
JohanAR 3-Mar-2008 [1368] | It works! :) thanks alot |
Will 4-Mar-2008 [1369] | what is the best way to convert this 4E-2 to 0.004 ? |
Oldes 4-Mar-2008 [1370x4] | formDecimal: func[ number [decimal!] digits [integer!] /local negative? p result ][ if digits <= 0 [return form to-integer 0.5 + number] if negative?: number < 0 [number: - number] p: power 10 digits result: form to-integer number * p + 0.5 if number < 1 [ insert/dup result "0" (1 + digits - length? result) ] if negative? [ insert result "-" ] head insert skip tail result negate digits #"." ] >> formDecimal 4E-2 4 == "0.0400" |
>> formDecimal (4E-2 / 10) 3 == "0.004" | |
hm.. maybe not the best as there is this issue: formDecimal 4E-3 2 == "0.00" | |
it depends what do you need... if is important the value or how the rounded value looks like | |
Will 4-Mar-2008 [1374] | thank you Oldes, I thought there was a native or mezz for that |
sqlab 9-Mar-2008 [1375] | a little bit late form-dec: func [ number [decimal!] ] [ form case [ number > 1 [number] number > 0 [ join "0" at form number + 1 2 ] number > -1 [ join "-0" at form number - 1 3 ] true [number] ] ] |
JohanAR 14-Mar-2008 [1376] | why does join 'a 'b return "ab" instead of 'ab ? |
Sunanda 14-Mar-2008 [1377] | join always returns a string unless the first value is of type? series. >> join 1 2 == "12" Try source join to see the actual code. |
[unknown: 5] 14-Mar-2008 [1378] | JohanAR, use this instead: attach: func [a b][to type? a join a b] |
JohanAR 14-Mar-2008 [1379x2] | thanks! |
On to the next question :) Why is '= valid but '< or '> aren't? | |
Geomol 14-Mar-2008 [1381x2] | My guess is, that it's becuase < and > are part of tag type, like <tag>. So it's a restriction to make value evaluation easier internally. |
>> blk: [=] == [=] >> blk: [<] ** Syntax Error: Invalid tag -- < ** Near: (line 1) blk: [<] >> blk: [<tag>] == [<tag>] | |
BrianH 14-Mar-2008 [1383] | >> type? first [<] ** Syntax Error: Invalid tag -- < ** Near: (line 1) type? first [<] >> type? first [ < ] == word! |
Geomol 14-Mar-2008 [1384] | hehe, funny! :) |
BrianH 14-Mar-2008 [1385x4] | I guess it is special-cased in the loader. |
>> attempt [[<]] ** Syntax Error: Invalid tag -- < ** Near: (line 1) attempt [[<]] >> attempt [load "[<]"] == none | |
This relates to the sandboxing discussion I was just having with Paul. | |
The first error isn't caught because the load happens before the attempt is called. | |
JohanAR 14-Mar-2008 [1389] | you can ofcourse use to-word "<" but it's not very good looking if you have to cover all of <, <=, >, >=, <> etc.. managed to avoid the case by using compose instead of reduce though |
JohanAR 15-Mar-2008 [1390] | Is it possible to define a function, which takes another function as argument and that the argument func must take exactly two arguments in it's turn? |
PeterWood 15-Mar-2008 [1391x5] | This is how you can pass a function to a function: >> a: func [a [function!]] [ print a 1 2] >> b: func [x [integer!] y [integer!]] [add x y] >> a :b 3 |
Sorry about the formatting; let my try again: >> a: func [a [function!]] [ print a 1 2] >> b: func [x [integer!] y [integer!]] [add x y] >> a :b 3 | |
I think you will need to "manually" check that the supplied function uses the correct number of arguments | |
>> c: func [a [function!]] [if 2 = length? first :a [print a 1 2]] >> c :b 3 | |
>> d: func [][print "no args"] >> c :d == none | |
older newer | first last |