Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Please help me out

 [1/23] from: emekamicro:gma:il at: 22-Aug-2010 17:46


Hello All, I have the below; kool: %gin.txt write kool "African" write/append kool "Child" Now, I would want to read the file , and print first "African", and second Child I tried read/lines kool == [ "AfricanChild"] I was looking for something like [ "African" "Child"] Regards, Emeka

 [2/23] from: izkata:gmai:l at: 22-Aug-2010 12:09


If you open the file in a text editor, you'll see that it does contain AfricanChild on one line. All that's needed is a newline in the middle: write kool "African" write/append kool newline write/append kool "Child" Alternatively, 'write has another refinement that could help here: write/lines kool "African" write/lines/append kool "Child" The /lines refinement works similar to read/lines - this would result in the same as the above: write/lines kool [ "African" "Child" ] On Sun, Aug 22, 2010 at 11:46 AM, Emeka <emekamicro-gmail.com> wrote:
> Hello All, > I have the below;
<<quoted lines omitted: 12>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- 奏でて夢

 [3/23] from: emekamicro:gma:il at: 22-Aug-2010 22:51


Hello All, Is [] a cousin of LISP list () (serving the purpose of procedure call and data structure) Regards, Emeka On Sun, Aug 22, 2010 at 6:09 PM, Izkata <izkata-gmail.com> wrote:

 [4/23] from: henrikmk:gma:il at: 23-Aug-2010 14:11


On Sun, Aug 22, 2010 at 11:51 PM, Emeka <emekamicro-gmail.com> wrote:
> Hello All, > > Is [] a cousin of LISP list () (serving the purpose of procedure call and > data structure)
I don't know LISP, but blocks are data and code containers. You can put any shape of data structure in them, that REBOL will load. Any element of any datatype can go into a block. Blocks are of the block! datatype and is a series! type, which means you can manipulate and traverse it with series! compliant functions like NEXT, BACK, HEAD, REMOVE, CHANGE, etc. All series! have an index and can store their current position. Blocks form a huge part of the "silly putty" method of working with REBOL. Another very important aspect is that all series are aggressively reused whenever possible. I call this the "copy trap", and it will bug you, if you don't know what's going on. Read more here: http://www.codeconscious.com/rebol/articles/rebol-concepts.html#Firsttrapforbeginners -- Regards, Henrik Mikael Kristensen

 [5/23] from: emekamicro:gm:ail at: 23-Aug-2010 13:47


Henrik and Izaka, Thanks so much. More blogs posts won't be harmful. Regards, Emeka On Mon, Aug 23, 2010 at 1:11 PM, Henrik Mikael Kristensen < henrikmk-gmail.com> wrote:

 [6/23] from: xapwing:gma:il at: 23-Aug-2010 14:51


Hi, the answer of Henrik is fine. To answer the "Lisp" part: in Rebol [x y] does not mean: - apply function x to argument y which in the Lisp list (x y) would be the case. [] in Rebol is just data. Regards, Arie 2010/8/22 Emeka <emekamicro-gmail.com>

 [7/23] from: emekamicro:gmai:l at: 23-Aug-2010 14:16


Arie, But when you apply func to [x y] it seems to me that it starts to behave like Lisp. Am I wrong? Emeka On Mon, Aug 23, 2010 at 1:51 PM, Arie van Wingerden <xapwing-gmail.com>wrote:

 [8/23] from: xapwing:g:mail at: 23-Aug-2010 16:09


No. In Lisp the x would be evaluated as being a function with arg y. In Rebol x is (generally speaking) not a function. Do you have a short example to show your confusion? 2010/8/23 Emeka <emekamicro-gmail.com>

 [9/23] from: edoconnor:gma:il at: 23-Aug-2010 11:09


I don't know much about computer science, but I think REBOL's blocks share some things in common with Smalltalk: http://web.cecs.pdx.edu/~harry/musings/SmalltalkOverview.html#Blocks REBOL's cool twist is that a block can hold code or data and treat them both equally/interchangeably, and can be accessed in a uniform manner (a data collection). In LISPy languages, the term 'thunk' might be the appropriate comparison. http://stackoverflow.com/questions/925365/what-is-a-thunk-as-used-in-scheme-or-in-general -- Ed On Mon, Aug 23, 2010 at 10:09 AM, Arie van Wingerden <xapwing-gmail.com>wrote:

 [10/23] from: emekamicro::gmail at: 23-Aug-2010 17:10


Hello All, This where I got my conclusion. I mentioned before that blocks are a container type. An ordered sequence of values. Actually they are an ordered sequence of un-evaluated values. What that means is that when a block itself is evaluated the values it contains are not evaluated. The values a block contains are evaluated when a function is applied to the block http://www.codeconscious.com/rebol/articles/rebol-concepts.html#Firsttrapforbeginners Is the last statement correct? Emeka On Mon, Aug 23, 2010 at 4:09 PM, Ed O'Connor <edoconnor-gmail.com> wrote: I don't know much about computer science, but I think REBOL's blocks share

 [11/23] from: xapwing:gm:ail at: 23-Aug-2010 19:26


Indeed that is the way it works. In Lisp a list (when unquoted!) is always evaluated. In Rebol evaluation is not standard, but must be triggered by a calling function (outside the block). And indeed also, when a block is being evaluated functions within the block will be recognized and evaluated also. 2010/8/23 Emeka <emekamicro-gmail.com>

 [12/23] from: btiffin:rogers at: 23-Aug-2010 17:13


On Mon, 23 Aug 2010 12:10:34 -0400, Emeka <emekamicro-gmail.com> wrote:
> Hello All, > This where I got my conclusion.
<<quoted lines omitted: 8>>
> is applied to the block > Is the last statement correct?
Properly, (and I've proven myself wrong in technical discussions about REBOL's inner workings on many occasions), I think a better expression would be The values a block contains are evaluated when the block is REDUCEd. I think. Cheers, Brian

 [13/23] from: emekamicro:g:mail at: 23-Aug-2010 22:23


Why REDUCEd? I am a bit confused now. Emeka On Mon, Aug 23, 2010 at 10:13 PM, Brian Tiffin <btiffin-rogers.com> wrote:

 [14/23] from: henrikmk:gma:il at: 24-Aug-2010 0:49


On Mon, Aug 23, 2010 at 11:23 PM, Emeka <emekamicro-gmail.com> wrote:
> Why REDUCEd? =A0I am a bit confused now.
I think it's easier to say that block values are not "live" i.e. they don't turn into something else as they are at no point evaluated and they do not necessarily reference anything, but the values may be bound somewhere (much deeper topic). You can then do various things to evaluate the content of the block or parts of it. REDUCE is just one of many ways: a: 4 b: 1 reduce [a b now] == [4 1 23-aug-2010/12:12:12] You can also DO the block. That is essentially just running REBOL code. do [a b now] == 23-aug-2010/12:12:12 One of the big strengths of REBOL is that you can look at that block in different ways: You can consider it a dialect, a sublanguage of your own design. You can look at it as raw data as input for a function or you can look at it as actual code, which is done above. When you treat the block as data, the values are usually not treated as live elements, but you are entirely free to do that. Here is the example above as a dialect: parse [a b now] [ any [set w ['a | 'b] (print ["you asked for a word" w])] 'now (print "looks like you asked for the time") ] you asked for a word a you asked for a word b looks like you asked for the time A side-effect of processing blocks like this, is that it makes it easy to make data transfers secure or the reading and inspection of foreign data. You can easily choose to evaluate a value in a block or perform a special action, if you don't think it's safe. I'm not sure it answers any of your questions, but maybe you'll understand a bit about the code vs. data aspect of REBOL. -- Regards, Henrik Mikael Kristensen

 [15/23] from: carl:cybercraft at: 24-Aug-2010 11:48


On Monday, 23-August-2010 at 22:23:53 Emeka wrote,
>Why REDUCEd? I am a bit confused now.
REDUCE is useful for returning a block that contains the contents of a blocks after its been evaluated. ie. from the console...
>> cat: "feline"
== "feline"
>> dog: "canine"
== "canine"
>> blk: [cat dog 1 + 1]
== [cat dog 1 + 1]
>> reduce blk
== ["feline" "canine" 2] Note that words, (ie 'cat and 'dog in blk), are just datatypes too. So while REDUCE might be one of REBOL's default functions, when in a block it's just a word to be used as you with. ie...
>>> b: [reduce blk 10]
== [reduce blk 10]
>> foreach value b [print [value "type:" type? value]]
reduce type: word blk type: word 10 type: integer Hope that doesn't add to the confusion! -- Carl Read.

 [16/23] from: btiffin:rogers at: 24-Aug-2010 3:09


It's a "belief" of mine. Data in blocks are just literal data until a REDUCE. Nifty cool data-type! data, but still just the literal data. Explicit or implicit in other words like DO or paren expressions in COMPOSE, to me REDUCE is one of the magic concepts that lets REBOL look and feel easy while being deep and vast. Now explaining part of the belief. It started dawning on me when I began the trek to figuring out what the heck lit-words were and why REBOL needs them. The rest is just example; ... being unable to explain REBOL in a way that is truthful and not just the look and feel easy bit. a: 42 b: 9 data: [a b] literaldata: ['a 'b] human: ['a 'is a 'and 'b 'is b] ; the type? of these entries is word! probe data [a b] probe reduce data [42 9] ; integer! reduces to the same integer! probe reduce reduce data [42 9] ; the type? of the entries is lit-word!, reduced to word! probe reduce literaldata [a b] probe reduce reduce literaldata [42 9] ; lit-word! mixed with word! probe reduce human [a is 42 and b is 9] ; the word is is not bound to a context that can give a value probe reduce reduce human ** Script Error: is has no value Cheers, Brian On Mon, 23 Aug 2010 17:23:53 -0400, Emeka <emekamicro-gmail.com> wrote:

 [17/23] from: emekamicro:gmai:l at: 24-Aug-2010 8:41


Brain + Carl + Henrik, Hmm, this is like standing on the shoulders of giants. Thank you all. Emeka On Tue, Aug 24, 2010 at 8:09 AM, Brian <btiffin-rogers.com> wrote:

 [18/23] from: lmecir:volny:cz at: 24-Aug-2010 12:27


Dne 23.8.2010 19:26, Arie van Wingerden napsal(a):
> Indeed that is the way it works. > In Lisp a list (when unquoted!) is always evaluated.
<<quoted lines omitted: 22>>
>> Emeka >>
...the rest snipped... The funny thing about the discussion above is, that although the contributors look like being in mutual agreement, their statements actually are not. Let me try to add my two cents in hope I do not add more confusion to the subject. First, let's examine the expression: do [ ; this is the "outer block" length? [ ; this is the "inner block" 1 ] ] Such an expression is quite frequently referred to as: "The (outer) block in the above expression is evaluated by the DO function." When describing, how the DO function interprets the (outer) block, the documentation sources say, that "The values and words of the block are computed from left to right." Notice, that the word used is not evaluated , but "computed". That is a necessary terminological distinction, since the inner block is not "evaluated" in the same way as the outer block is, it is just "computed", which actually means, that the inner block is supplied "as is" to the LENGTH? function. In this case, the LENGTH? function does not do any further "evaluation" of the inner block, it just yields the length of the inner block as its result. Hope, that this "terminological detour" was of some help. -Ladislav P.S. the usage of the "un-evaluated values" notion I see as quite unfortunate, since it looks more confusing than explaining.

 [19/23] from: emekamicro:g:mail at: 24-Aug-2010 12:18


Ladislav, Your 2 cents worths more than my 50 cents Thanks. Emeka 2010/8/24 Ladislav Mecir <lmecir-volny.cz>

 [20/23] from: Steven:Oldner:LA:GOV at: 24-Aug-2010 6:34


Ouch, my head hurts. Just wanted y'all to know that us lurkers really appreciate these types of discussions.

 [21/23] from: gerardcote:g:mail at: 24-Aug-2010 8:50


Hi all, Just in case you missed it in the past, here is some discussion that went between Josh F and Maxim recently and that I found last July 24th. This can be of interest too since it is related - Sorry I couldn't post the link only as I didn't kept the reference, only the contents. ============= = JoshF post : ============= I have a very strange problem with REBOL/View 2.7.6.3.1... If I do this: repeat i 5 [do [print i]] I get five number down the screen as you'd expect. ------------------------------ ----------------- 1 2 3 4 5 However, if I do this: m: [print i] repeat i 5 [do m] Then I get a "** Script Error: i has no value ** Near: print i" error. ----------------------------------------- and Oh, by the way... m: [print i] repeat i 5 m works just fine too. ---------------------------------- As far as I can tell the operations should be identical. Any ideas as to what I'm doing wrong? Thanks! ========================= = Maxim Olivier Adhloch reply : ========================= its a binding issue... you see the i variable is within a block which is evaluated by do, but the binding of the [do m] block is done by repeat. as such, binding does not traverse words. repeat will assign the value of m to your block, but not the values of the words inside of m to i or print. in fact, do is doing this indirectly when its looking at the block. but because i isn't defined outside of repeat... i maps to nothing. now repeat did bind m, but not the values inside of m . this is perhaps the trickiest part of binding. a word and its value are not equal wrt to binding... you will have to reduce the repeat block, so that m is reduced or composed into its value, before repeat can bind 'i . in a very old version of rebol there was "aggressive" binding and it did recurse into words, like you are expecting it, but that caused some impossible to reverse side-effects... so this was removed. in your case, just do: m: [print i] repeat i 5 reduce [ 'do m] ---------------------------------------------------- or m: [print i] repeat i 5 compose/only [ do (m) ] ------------------------------------------------------------------ In fact if I apply the recomendation from Ladislav, using compute instead of eval could have made the real sense easier to grasp from the beginning - at least to me ! Thanks all of you. HTH, Gerard P.S. Now all that is missing for me is some in context use for a real binding study, as could be applied to differents "contexts" - for example when words are not bound to the main R2 dictionary store. This already bogged me down and I have to restart these old projects ... whenI will have more time - just to see if I understand these concepts better now ... after all these long years going up and down myself !

 [22/23] from: semseddinm:bircom at: 24-Aug-2010 16:05


And of course this will do the job: m: [print i] repeat i 5 [do bind m 'i] this will bind the m into the context of i (which is context of repeat) before DOing it. Tue, 24 Aug 2010 15:50:32 +0300 tarihinde Grard Ct <gerardcote-gmail.com> yle yazm:

 [23/23] from: lmecir:volny:cz at: 24-Aug-2010 15:18


Dne 24.8.2010 14:50, Grard Ct napsal(a): ...snip...
> In fact if I apply the recomendation from Ladislav, using compute instead of > eval > could have made the real sense easier to grasp from the beginning - at least > to me !
The terminological problem of the proper usage of the word "evaluation" is quite deep. In my contribution I cited some documentation sources. There is an alternative, as I recently mentioned in CureCode #1641. In my opinion, it makes sense to use the word "evaluation", "evaluate", etc. for expression evaluation. When used this way, we obtain: 1) In REBOL expressions, blocks evaluate to themselves. 2) REBOL blocks supplied as arguments to interpreting functions (like the DO function) are "interpreted" by the respective functions. Note, that the DO function is not the only interpreter function there is. As an example, the PARSE function interprets REBOL blocks as matching rules, using the Parse dialect. You can easily define your own block-interpreting functions, creating new REBOL dialects as often as you like. -Ladislav

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted