World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
Steeve 19-May-2009 [2743] | Final definition: All functions in Rebol that Carl don't want code as natives are called "mezzanines" |
Janko 19-May-2009 [2744] | :)) |
Steeve 19-May-2009 [2745] | Perhaps a new group "Bash Carl" should be more convenient |
Janko 19-May-2009 [2746] | O don't want to be in that group :) |
Maxim 19-May-2009 [2747] | all functions written in rebol, *shipped with rebol* are mezzanines. |
Henrik 20-May-2009 [2748] | Janko: http://hmkdesign.dk/rebol/files/385cc7420409fa08f768a537a52ce4d8-76.html |
Janko 20-May-2009 [2749] | thanks guys, very nice article Henrik! |
Oldes 20-May-2009 [2750] | very ugly link:] |
Henrik 20-May-2009 [2751] | That's RapidWeaver. :-) |
Geomol 20-May-2009 [2752] | Good short article, Henrik. The link to me is outdated. You can use http://john.niclasen.name/, if it's needed. |
BrianH 20-May-2009 [2753x2] | Nice article. The Google ads are funny too :) |
You missed op! functions, but that is probably OK. | |
mhinson 21-May-2009 [2755] | Hi, I am puzzling over this and would really appreciate some pointers please. How do I get from this: d1: "random1" d2: "data2" ;;to this? b1: [random1 ["data2"]] so I can reference the data2 by its association with random1 e.g. b1/random1/1 |
Henrik 21-May-2009 [2756] | well: b1: reduce [to-word d1 reduce [d2]] |
mhinson 21-May-2009 [2757x3] | ah, nice. Thanks. I was looking here http://www.rebol.com/docs/core23/rebolcore-16.html#section-3.10 which for once looks like it was the right area. Thank you. |
I was hoping to get something like this working with the data structure Henric helped me with above. foreach bb b1 [ print b1/:bb/1] but the foreach itterates all the vlaues, not just the words. I have been thinking about this for a week or so, but dont really know how to get any further with it. I suspect that if I had the right structure I could use it to store my data, then add additional details when I find some more, and finaly export the whole lot, grouped together by the key value (that I will only know when the script is running). Im aproaching this in the right sort of way? Or is there a recognised way to create these sort of structures please? | |
Sorry about my typing Henrik. I know how to spell your name really. | |
BrianH 21-May-2009 [2760] | foreach [key val] b1 [print val] |
mhinson 21-May-2009 [2761] | That is just what I wanted, thanks Brian. Is this a recognised way to deal with data that is presented in a different order to the output requirement? |
BrianH 21-May-2009 [2762x2] | No, it's just a way to treat a block as fixed records, this time of two values each. |
If you want variable records you either put the data in an inner block (as you have), or use a distinct datatype for the keys ans search for values of that datatype to find the next key. | |
mhinson 21-May-2009 [2764] | I think I need to learn more before I can use this to the effect I need. I was expecting your construct to all me to do this: foreach [key val] b1 [print b1/:val/1] |
BrianH 21-May-2009 [2765] | I don't get what you want to do. Perhaps some sample data and the desired output? |
mhinson 21-May-2009 [2766] | probe b1 [random3 ["data4"] random1 ["data2"]] probe b1/random1/1 data2 but as I dont know what random1 is I want to enumerate the values from the data structure. |
BrianH 21-May-2009 [2767] | Are you trying to get a specific data* or to enumerate all of random*? |
mhinson 21-May-2009 [2768] | Ah I think I am being a numpty. your structure already returns the data, but I need to be able to print the keys with the associated data. |
BrianH 21-May-2009 [2769x2] | foreach [r d] b1 [print [r d]] |
You can do some formatting in the print statement, but it is that easy. | |
mhinson 21-May-2009 [2771] | I will have different numbers of data elements in different keys, so I also need to keep track of which data is stored where, perhaps I need an array as the data element. |
BrianH 21-May-2009 [2772x3] | Your data already has an array as the data element, except we call them blocks. |
b1: [random3 ["data1" "data2"] random1 ["data3"]] | |
foreach [r d] b1 [print [r mold d]] | |
mhinson 21-May-2009 [2775] | I need to know what type of data I have put in data3. It might be the same type as in data1 or data2, or something different again. any one of maybe 10 types. The actual data will be IP addresses & interface details & remote connection information. |
BrianH 21-May-2009 [2776x3] | You can specify ip addresses directly, as data of the tuple! type. Or you could have the data be doubles of strings and type flags. |
Or if you would have at most one of each type, you could name the potential fields and have the data be name value pairs. | |
*a block of* name value pairs. | |
mhinson 21-May-2009 [2779] | most of my different types will be strings I am expecting. Sometimes there will be up to about 4 of the same type (addresses & secondary addresses mostly) |
BrianH 21-May-2009 [2780x2] | [key [flags ["flag1" "flag2"] ips ["127.0.0.1" "192.168.1.1"]] |
Sorry, missing a last ] | |
mhinson 21-May-2009 [2782] | The pairs idea sounds productive, so it is a highly structured array with named groups? |
BrianH 21-May-2009 [2783x2] | Or you could go positional for the different types of data, instead of including the flags and ips words all of the time. dat: [key [["flag1" "flag2"] ["127.0.0.1" "192.168.1.1"]]] foreach [key val] dat [set [flags ips] val ...] |
Structured data makes things easier. | |
mhinson 21-May-2009 [2785] | Thank you very much for you time & help. I will need a while to digest this & make it work with my existing code. I think this type of structure is going to be the core of most of the data extraction I need to do, so I must get to understand it very well. I have a section that uses an array, but some of the more interesting data manipulation needs to cope with more varied keys. Thanks. |
BrianH 21-May-2009 [2786] | This a pretty standard way for REBOL to do lightweight data structures. Blocks are lighter-weight than objects. Enjoy :) |
RobertS 22-May-2009 [2787] | . |
mhinson 22-May-2009 [2788x2] | Hi, is there an easy way to make this sort of structure work please? data: [bike [wheels [2] owner [john]] pig [legs [4] owner [roger]]] foreach [thing content] data [print [data/:thing/owner "~" data/:thing/wheels "~" data/:thing/legs]] I want the invalid references (e.g. data/bike/legs) to return nothing so the list is printed for both things |
I know I could put "" values in when I create the structure, but I wondered if the was a neater way to do this. | |
Henrik 22-May-2009 [2790x2] | if you wrap a path in ATTEMPT, it will return none. |
when it doesn't exist | |
mhinson 22-May-2009 [2792] | Thanks Henrik. That sounds like what I need. |
older newer | first last |