Paste: prefix-words

Author: noam
Mode: factor
Date: Sat, 17 Dec 2011 19:14:56
Plain Text |
USING: accessors kernel locals math parser sequences words ;
IN: prefix-words

SYNTAX: if:
    2 [ scan-object suffix! ] times
    \ if suffix! ;

SYNTAX: PREFIX-WORD:
    scan-word [ name>> ":" append create-in ] keep scan-number
    [
        [ [ scan-object suffix! ] times suffix! ] 2curry
        define-syntax
    ] 3curry append! ;

Annotation: code

Author: noam
Mode: factor
Date: Sat, 17 Dec 2011 19:25:00
Plain Text |
SYNTAX: PREFIX-WORD:
    scan-word [ name>> ":" append create-in ] keep scan-number
    [ [ scan-object suffix! ] times suffix! ] 2curry
    define-syntax ;

Annotation: fix

Author: rien
Mode: factor
Date: Sat, 17 Dec 2011 19:32:43
Plain Text |
IN: prefix-words SYNTAX: PREFIX-WORD:
    scan-word [ name>> ":" append create-in ] keep scan-number
    [ [ scan-object swapd suffix! ] times swap suffix! ] 2curry
    define-syntax ;
IN: prefix-words PREFIX-WORD: when 1
IN: prefix-words t when: [ "hey" . ]
"hey"

New Annotation

Summary:
Author:
Mode:
Body: