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

World: r3wp

[Core] Discuss core issues

[unknown: 5]
20-Feb-2008
[9267]
That sounds less confusing.
Ingo
20-Feb-2008
[9268x2]
Evaluates conditions until a condition is true, then evaluates the 
associated value.
("what follows it" could be all the rest ...)
[unknown: 5]
20-Feb-2008
[9270]
So let me play newbie for a moment.  If I see your phrase I might 
think that case is going to evaluate each condition until that condition 
is true and then evaluate what follows it.  Similiar to an until 
function.
Ingo
20-Feb-2008
[9271]
Evaluates the conditions, until the first true condition is found. 
Then evaluates the associated value.
[unknown: 5]
20-Feb-2008
[9272x2]
Anyone have information on the STATS command.  I'm trying to find 
some comprehensive information on it.  I remember at one time there 
was a discussion regarding using stats to measure performance of 
functions, etc..
Not just memory usage.
btiffin
20-Feb-2008
[9274]
stats/evals is handy.   Use it with  stats/evals/clear   And then 
look at rebol.org's  mem-stats.r  by Carl.  It's not "comprehensive 
info" but it's info.   :)
Anton
20-Feb-2008
[9275]
I think "next value" is more precise than "associated value".
[unknown: 5]
20-Feb-2008
[9276]
thanks Btiffin.  I'll look for Carl's mem-stats.r function also.
james_nak
22-Feb-2008
[9277]
I don't know where to put this question exactly but has anyone created 
any code to generate an Outlook appointment request?
Gregg
22-Feb-2008
[9278]
I did some MAPI test R&D a long time back, though I think I wrapped 
it in a DLL to call from REBOL. 

Can you generate an iCal %.ICS file and do it that way?
[unknown: 5]
22-Feb-2008
[9279]
The valuable?/potential? function would have to be updated.  It needs 
to check for value.  so it would be:


valueable?: func [arg][found? all [any-word? :arg not lit-word? :arg 
value? :arg]]
Rod
23-Feb-2008
[9280]
I am trying to pull some information out of a moderately formatted 
wiki and am tripping over something simple.


I have grabbed what equates to a record in a table so far that looks 
as follows.

||Key 123||Description text||Status||02/23/08||Y||

I have parse giving me this as a block of values.


Since this wiki is only loosely formatted the first field varies 
one line to the next, sometimes might just be Key, or *Key ###.  
What I am working too hard at is how to test a line is a pure Key 
### value.  I went looking using find for "Key "(with the space) 
 values but that still picks up "*Key ###" values.  I have multiple 
key types but generally it follows the pattern of trying to avoid 
the leading * lines and any line that isn't a known Key with some 
number following it.


My old procedural habits would like a simple substring so I can test 
from the beginning for x number of characters.


I have tried copy/part but am not getting the range syntax correct.


I am also thinking I should just further split the field to the key+number 
so I can test that both parts exist and have appropriate values. 

Suggestions or nudges towards enlightenment?
btiffin
23-Feb-2008
[9281x2]
Umm, I'll get this wrong; but parse is the ticket.

nums: make bitset! [#"0" - #"9"]
valid: parse value [ "Key" 3 nums]

I think.
space: make bitset! " "
valid: parse/all value ["Key" space 3 nums space to end]

Maybe?
Brock
23-Feb-2008
[9283x3]
I'd include a characterset that excludes the * character
sorry bitset... 
nums: make bitset! [#"0" - #"9"]
skip-char: complement make bitset! [#"*"]
valid: parse value [skip-char "Key" " " 3 nums]
... something to that affect anyway.
Ingo
23-Feb-2008
[9286]
How about:

nums: charset [#"0" - #"9"]
space: charset [#" "] 

parse wiki ["||" any space "key" any space 3 nums any space "||" 
] 
and so on ...]
Rod
23-Feb-2008
[9287]
Brian, the first one seems to work for my test data, will give it 
a try on the real thing on Monday.  Thanks all for the tips, will 
keep them handy as I refine this little script.
Graham
23-Feb-2008
[9288]
Anyone got a clean-script that works with the new rebol syntax ?
[unknown: 5]
23-Feb-2008
[9289]
Is there an easy way to remove double blocks from a block.  So that 
something that looks like [[something]] looks like [something]?  
If not shouldn't we have something like this in REBOL as a mezz function?
Henrik
23-Feb-2008
[9290x2]
this has been discussed before, but I think the solution has scrolled 
out of view a long time ago...
R3 can do it using the new methods that loops can use, I believe.
[unknown: 5]
23-Feb-2008
[9292]
Are you saying it can't be done until R3?
Henrik
23-Feb-2008
[9293x3]
it can easily be done. the simplest way is:
form [[1][2][3]]
but it has limitations
[unknown: 5]
23-Feb-2008
[9296]
Can you expland on the limitations?
Henrik
23-Feb-2008
[9297x3]
you lose bindings and it won't work on series inside the blocks inside 
the block.
oops, it should be to-block form [[1][2][3]]
there are better solutions, but that is the quickest one.
[unknown: 5]
23-Feb-2008
[9300]
That is how I do also Henrik, I would be interested in a better solution 
but I was thinking we need one to handle the blocks within blocks
Henrik
23-Feb-2008
[9301]
the only other way in R2 is to process each block one by one with 
a loop
[unknown: 5]
23-Feb-2008
[9302]
I can build the function to loop through a block looking for others 
but am curious about the effect on bindings.
Henrik
23-Feb-2008
[9303]
I think we made a 'flatten function once.
[unknown: 5]
23-Feb-2008
[9304x2]
good name
Tell me more about in what way you think the bindings will get lost.
Henrik
23-Feb-2008
[9306x2]
with FORM you always lose bindings
try searching for flatten in AltME. plenty of references to it, I 
can see here.
[unknown: 5]
23-Feb-2008
[9308x2]
But I can only think that bindings would be lost for those blocks 
assigned as a value to a word
Seems it would still be useful for data taken from a stream of string 
data
Henrik
23-Feb-2008
[9310]
I can't calculate in my head when exactly the bindings are lost, 
so I would suggest simply experimenting in the console.
[unknown: 5]
23-Feb-2008
[9311]
Yeah I definately think that would be the case for set-words that 
contain block values but should be no problem on passing block data 
to set-words that are currently not set.
Gregg
23-Feb-2008
[9312]
flatten: func [blk [block!] /local res rule value] [
    	res: copy []

     rule: [some [into rule | set value skip (append res :value)]]
    	parse blk rule
    	res
    ]
[unknown: 5]
23-Feb-2008
[9313x2]
Here is a function for when you just want part of the block's flattened 
for when you reduce a bunch of data and want to use select on the 
data:

semi-flat: func [blk /local blk2][
    while [not tail? blk][
        if block? blk/1 [
            blk2: copy blk/1
            insert remove blk blk2
            blk: next next blk
        ]
    ]
    blk: head blk
]
>> data: [[1 ["record1"]] [2 ["record2"]] [3 ["record3"]]]
== [[1 ["record1"]] [2 ["record2"]] [3 ["record3"]]]
>> semi-flat data
== [1 ["record1"] 2 ["record2"] 3 ["record3"]]
>> select data 2
== ["record2"]
>> select data 3
== ["record3"]
Anton
23-Feb-2008
[9315x2]
Paul, you can avoid copy blk/1 by using change/part.

And perhaps better to continue processing the data when blk/1 is 
not a block.
semi-flat: func [blk][
    while [not tail? blk][
        blk: either block? blk/1 [
            change/part blk blk/1 1
        ][
	    next blk
	]
    ]
    head blk
]

semi-flat [[1 ["one"]] [2 ["two"]] "other data"]