Paste: cursors

Author: prunedtree
Mode: factor
Date: Wed, 15 Oct 2008 04:24:42
Plain Text |
:: compress-path ( source assoc -- destination )
    [let | destination [ source assoc at ] |
        source destination = [ source ] [
            [let | destination' [ destination assoc compress-path ] |
                destination' destination = [
                    destination' source assoc set-at
                ] unless
                destination'
            ]
        ] if
    ] ;

: (compress-path') ( source-cursor -- destination-cursor )
    dup [ value>> ] [ key>> ] bi = [
        dup value>> >>key (compress-path')
        dup [ value>> ] [ key>> ] bi = [ dup value>> >>value ] unless
    ] unless

: compress-path' ( source assoc -- destination )
    >cursor swap >>key (compress-path') value>>

Annotation: better ? (no 'fake' accessors)

Author: prunedtree
Mode: factor
Date: Wed, 15 Oct 2008 04:28:01
Plain Text |
: (compress-path') ( source-cursor -- destination-cursor )
    dup [ value>> ] [ key>> ] bi = [
        dup value>> with-key (compress-path')
        dup [ value>> ] [ key>> ] bi = [ dup value>> set-value ] unless
    ] unless

Annotation: and of course...

Author: prunedtree
Mode: factor
Date: Wed, 15 Oct 2008 04:30:05
Plain Text |
: key-value>> ( cursor -- key value ) [ value>> ] [ key>> ] bi ;

: (compress-path') ( source-cursor -- destination-cursor )
    dup key-value>> = [
        dup value>> with-key (compress-path')
        dup key-value>> = [ dup value>> set-value ] unless
    ] unless ;

Annotation: correction

Author: prunedtree
Mode: factor
Date: Wed, 15 Oct 2008 04:32:59
Plain Text |
:: (compress-path') ( source-cursor -- destination-cursor )
    dup key-value>> = [
        dup value>> with-key (compress-path')
        dup key-value>> = [ dup value>> source-cursor swap set-value ] unless
    ] unless ;

New Annotation

Summary:
Author:
Mode:
Body: