Differences From Artifact [6624c3fd41f2b232]:
File user/crc/patengi.retro part of check-in [5a309ea759] - start updating crc's toys to work with retro 11 image by crc on 2011-03-14 20:17:26. [annotate] [view]
To Artifact [d98ef3d783c4940c]:
File user/crc/patengi.retro part of check-in [f0269c2f92] - add "grep" example by crc on 2011-03-21 16:22:18. [annotate] [view]
@@ -1,52 +1,9 @@ -chain: db::core' - ( --- tools for dealing with lists --- ) - : deep ( an-a) 0; &@ times ; - : deepest ( a-a ) repeat dup @ 0; nip again ; - : link, ( a- ) here 0 , swap deepest ! ; - : prop ( a"-a) @last swap !last ' swap !last ; +: getType getToken &types' findInChain [ @d->xt ] [ drop -1 ] if ; +: fields ( n""- ) [ create getToken , getType , ] times ; - ( --- tables: fields/offsets, rows/links, etc. --- ) - 2 elements table row - : save ( "- ) @table constant ; - : load ( a- ) @dup !row !table ; - : link @table ; ( least recent row added ) - : size link 1+ ; ( number of fields ) - : head size 1+ ; ( header for last field ) - : fields - @last swap dup [ ' create swap , , ] iter - here !table 0 , , @last , !last ; - : f:num @ ; - : f:xt f:num @row + @ ; - : f:fun 1+ @ ; - : f:pair dup f:xt swap f:fun ; - : num:f @head swap 1- deep @d->xt ; - : name:f @head prop ; - : row, ( a- ) here !row link link, @size allot ; - : insert ( n"- ) name:f f:num @row + ! ; - : nwhere ( n- ) @link swap deep !row ; - : 3dup dup [ 2over &-rot dip ] dip ; - : match? ( ana- ) 3dup + @ compare ; - : where ( a"- ) name:f f:num @link - repeat match? [ !row drop 0 ] ifTrue 0; @ again ; - : select ( "- ) name:f f:xt ; - : select-list ( n"- ) [ name:f f:pair cr withClass ] times ; - : select-all ( - ) @size [ num:f f:pair cr withClass ] iter ; -;chain +bye -with db::core' - -chain: db::io' - ( --- output types --- ) - : chars [ @+ putc ] times ; - : string: .data ` puts ; immediate - : num: .data ` putn ; immediate - ( --- input methods --- ) - : keep: here repeat getc dup '~ = [ drop 0 , 0 ] ifTrue 0; dup putc , again ; - : number: here swap , ; -;chain - -with db::io' ( --- example table --- ) 5 fields string: title string: author string: genre string: series num: year save books