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

World: r3wp

[Rebol School] Rebol School

Ladislav
12-Jul-2011
[3707]
Moreover, BNFs, general formal grammars, etc... are actually systems 
that are meant to be usable for humans as well (at least mostly), 
in which case there is no implementation you could show to other 
people. (somebody wanting to show an x-ray picture of a human brain, 
or what???)
BrianH
12-Jul-2011
[3708]
There is no general best way to teach parsing. Most people (if you 
include non-programmers) won't be able to learn it with any method. 
For the people who can learn it, different methods are more effective 
for different people. For some people, reading the source is the 
best method. For most others it isn't. Teaching hard subjects is 
hard.
Maxim
12-Jul-2011
[3709]
yep.
Geomol
12-Jul-2011
[3710]
I agree. Late studies in learning show, some children learn by doing, 
some need to hear it explained, some can learn by reading, some need 
to do something physical while learning, etc. I guess, it's the same 
with adults.
BrianH
12-Jul-2011
[3711x2]
I worked on a project that failed because it depended on teaching 
parsing to unskilled data entry people - not my idea, and I couldn't 
explain to the people in charge why it was a bad one, because even 
teaching that was hard. It would be great if it were otherwise.
Actually, it depended on unskilled data entry people being able to 
write parse specs without being taught - even worse.
Geomol
12-Jul-2011
[3713]
I couldn't explain to the people in charge why it was a bad one


Many people in charge isn't well positioned for their job. And they're 
often very hard to fire.
Maxim
12-Jul-2011
[3714x2]
yeah, its probably deeply rooted into how skill someone is at perceptions 
of different types.  


its like trying to dance with an arythmic person... they just can't 
do it even if they love the music!
(last comment related to Geomol's comment on learning)
Steeve
12-Jul-2011
[3716]
- "You're unable to convince someone to change his mind with a logical 
argument, If that someone is wrong because of illogical ruling." 
I don't remember the exact citation
Maxim
12-Jul-2011
[3717]
shit it - shit out   ;-)
Steeve
12-Jul-2011
[3718]
Sorry I should have say "parameter" instead of "argument"
Or maybe not ;-)
Maxim
12-Jul-2011
[3719x2]
(as opposed to   shit in - shit out     hehe that wasn't a typo... 
it might have been too subtle)
are you mixing up groups?
Steeve
12-Jul-2011
[3721x2]
lol
I was reacting to that one:
I couldn't explain to the people in charge why it was a bad one
Awi
10-Aug-2011
[3723]
Is there something like reform/with ["id" "name" "address" "city"] 
","
where there result will be "id,name, address,city" in rebol?
Awi
11-Aug-2011
[3724]
I've found a solution replace/all reform ["id" "name" "address" "city"] 
" " ","
Sunanda
11-Aug-2011
[3725]
That may not always give you what you'd expect  if the strings have 
embedded spaces:

    replace/all reform ["id" "last name" "address" "city"] " " ","
    == "id,last,name,address,city"

This may work better in that situation:

    skip head remove back tail remove back tail  replace/all mold ["id" 
    "last name" "address" "city"]  {" "} ","  2
Henrik
11-Aug-2011
[3726x2]
it would be so nice to have an interleave function, or an opposite 
of extract.
reform interleave ["id" "name" "address" "city"] ","
Awi
11-Aug-2011
[3728x3]
Thanks Sunanda for pointing the issue, this should have saved me 
from debugging predictable error in the future :-)
@Henrik: I just read about ReBin http://www.rebol.com/article/0044.html
. Yes, this would be what I'm looking for. A binary representation 
of valid Rebol values.
sorry, wrong chatroom
Endo
11-Aug-2011
[3731x3]
I'm using this function to do that:

merge: func [b [block!] /local t r] [parse b [some [t: any-type! 
(append r: "" join form first t either tail? next t [""][","])]] 
r]
>> merge ["a" 5 *]
== "a,5,*a,5,*"
can be easily extended to use optional separator char.
Oops! Sorry small mistake, here is the correct one :)

merge: func [b [block!] /local t r] [r: copy "" parse b [some [t: 
any-type! (append r join form first t either tail? next t [""][","])]] 
r]
Gregg
11-Aug-2011
[3734x3]
Here's my version.
; A dialected version of this could be very flexible; allowing more
    ; than just fixed size groupings.

    ; This could also be done by adding a /SKIP refinement to INSERT.
    delimit: func [
        ;[throw catch]
        "Insert a delimiter between series values."
        series [series!] "Series to delimit. Will be modified."
        value            "The delimiter to insert between items."

        /skip   ;<-- be sure to use system/words/skip in this func

            size [integer!] "The number of items between delimiters. Default 
            is 1."
    ][

        ; Hmmm, I wonder if we could extend the function spec dialect

        ; to include constraints like this declaratively? And should

        ; we trap the arg like this, or just use MAX to make sure we

        ; have a positive value? I think I'll do the latter for now,
        ; but leave this here as a comment.
        ;if all [size not positive? size] [
        ;    throw make error! join [script invalid-arg] size
        ;]
        ; By default, delimiters go between each item.
        ; MAX catches zero and negative sizes.
        size: max 1 any [size 1]

        ; If we aren't going to insert any delimiters, just return the series.

        ; This check means FORSKIP should always give us a series result,
        ; rather than NONE, so we can safely inline HEAD with it.
        if size + 1 > length? series [return series]
        ; We don't want a delimiter at the beginning.
        series: system/words/skip series size

        ; Use size+n because we're inserting a delimiter on each pass,

        ; and need to skip over that as well. If we're inserting a

        ; series into a string, we have to skip the length of that

        ; series. i.e. the delimiter value is more than a single item
        ; we need to skip.
        size: size + any [

            all [list? series  0] ; lists behave differently; no need to skip 
            dlm.

            all [any-string? series  series? value  length? value]
            all [any-string? series  length? form value]
            1
        ]
        head forskip series size [insert/only series value]
    ]
make-csv: func [block] [rejoin delimit copy block #","]
Endo
12-Aug-2011
[3737x2]
Nice indeed.
Here is improved version of mine:

merge: func [
	"Merge a block using a delimiter. Default is coma."
	b [block!] "Block to merge."
	/with c [char! string!] "Delimiter char or string."
	/local t r
] [
	r: make string! 64
	c: any [c ","]
	parse reduce b [some [t: any-type! (
		append r join first t either tail? next t [""][c]
	)]]
	r
]
>> merge [a "x" 234 '*]
== "5,x,234,*"
>> merge/with [a "x" 234 '*] ":"
== "5:x:234:*"
>> merge/with [a "x" 234 '*] "---"
== "5---x---234---*"


Benchmark results are almost same with Gregg's. Executing the function 
for 1 million times take 16, 17 second for both on my machine, core 
2 duo, 2.8 Ghz, xp pro.
sqlab
12-Aug-2011
[3739]
since many years I use this function from  Andrew from time to time
rejoin: func [ 
    "Reduces and joins a block of values." 
    block [block!] "Values to reduce and join" 
    /with string; [ string! ] 
][ 
    if empty? block: reduce block [return block] 

    if with [ block: next block forskip block 2 [ insert block string 
    ] ] 
    block: head block 
    append either series? first block [copy first block] [ 
        form first block] next block 
]
Awi
12-Aug-2011
[3740]
This is all great, many thanks!
Marco
20-Aug-2011
[3741]
Is it possible to "copy" a face?

I want to open a window with some gadgets, the user modifies them 
but then I want to restore the previous situation.
This does not work:

win: layout [slider 100x20]
win-copy: make win []
view win
win: make win-copy []
view win


If you move the slider in the first window it appears the same in 
the second.
Any hint? Thanks in advance.
Henrik
20-Aug-2011
[3742]
better or easier to simply layout the same layout twice.
Sunanda
20-Aug-2011
[3743]
Would using multiple layouts and subpanels do what you are looking 
for?
   http://www.rebol.com/how-to/subpanels.html
Gregg
20-Aug-2011
[3744]
When you call LAYOUT, REBOL interprets the VID spec and creates face 
objects. Faces are nested objects. If you do some expermenting in 
the console, with making objects that contain nested objects, then 
making other objects from those, it may help. The SAME? function 
is very handy when comparing  objects and blocks as well.
Marco
21-Aug-2011
[3745]
The things are a bit more complicated. The situation is this:

win-copy: copy/deep win: [
	slider 100x20 across
	btn "ok" [win-copy: make win [] hide-popup]
	btn "Cancel" [win: make win-copy [] hide-popup]
]
win: layout win
win-copy: layout win-copy
view layout [btn "second win" [inform win]]


When the user presses ok the win layout should be copied to the win-copy 
face,

when the user presses Cancel the win-copy layout should be copied 
to the win face

so when the user presses ok it appears the previous modified layout,

when the user presses cancel it appears the previous layout but unmodified.

Obviously I could copy the faces values but in my application there 
are a lot
of gadgets and this would be a more general and simple solution.
Henrik
21-Aug-2011
[3746]
I'm not sure I understand entirely. Are you simply trying to store 
the face values?
shadwolf
21-Aug-2011
[3747x7]
rebol school without a proper documentation on parse how futile is 
that ?
first properlt explain n parse from nothing to makedoc pro level 
parse then you will have a cahnce to stand as a rebol school
you guys talk big but act low and it's your responsability to proove 
me wrong with FACTS with documents
how is it that rebgui brought the shit out of me and that RMA just 
 let me unsensible  ?
yeah you try to avoid this conversation cause it doesn't suits you 
be please do the effort lower your godess self to my level and have 
a proper discussion I let you live for the  past year with humm  
the less possible of my hate and ranting so  now be man anough to 
face my full power
and be aware I'm not this noob around I' m a ten year contributor 
 of rebol bringing stuff I was the only one to bring  sone how I 
managed to get myself  helped this has to be acknoleged liek the 
fact that now  in day the only rebol dicionary in french is due  
to me
I  LOVE REBOL I  AM COMITED TO REBOL  AND IT MAKES ME SUFFER THE 
SITUATION WE ARE IN ... rebol is suich a great work that even his 
author ran far from it how sensless is that ?
Marco
21-Aug-2011
[3754]
@Henrik If you move the sli
shadwolf
21-Aug-2011
[3755x2]
you all forgot about the basic rebol = carl  no carl no rebol that 
it  .. why commenting r3 mopre than r2 and if we comment r2 can we 
do it forgetting about rebplug rebservices rebplug etc ?
rebcode ?