Merge branch 'master' of git://factorcode.org/git/factor
commit
85e8141353
|
@ -95,7 +95,7 @@ PRIVATE>
|
|||
[ [ see ] with-string-writer \ $code swap 2array ] bi 3array ; inline
|
||||
|
||||
: (fuel-word-def) ( name -- str )
|
||||
fuel-find-word [ [ def>> pprint ] with-string-writer ] when* ; inline
|
||||
fuel-find-word [ [ def>> pprint ] with-string-writer ] [ f ] if* ; inline
|
||||
|
||||
: (fuel-vocab-summary) ( name -- str ) >vocab-link summary ; inline
|
||||
|
||||
|
|
|
@ -14,7 +14,17 @@ HELP: undo
|
|||
HELP: define-inverse
|
||||
{ $values { "word" "a word" } { "quot" "the inverse" } }
|
||||
{ $description "Defines the inverse of a given word, taking no arguments from the quotation, only the stack." }
|
||||
{ $see-also define-pop-inverse } ;
|
||||
{ $see-also define-dual define-involution define-pop-inverse } ;
|
||||
|
||||
HELP: define-dual
|
||||
{ $values { "word1" "a word" } { "word2" "a word" } }
|
||||
{ $description "Defines the inverse of each word as being the other one." }
|
||||
{ $see-also define-inverse define-involution } ;
|
||||
|
||||
HELP: define-involution
|
||||
{ $values { "word" "a word" } }
|
||||
{ $description "Defines a word as being its own inverse." }
|
||||
{ $see-also define-dual define-inverse } ;
|
||||
|
||||
HELP: define-pop-inverse
|
||||
{ $values { "word" "a word" } { "n" "number of arguments to be taken from the inverted quotation" } { "quot" "a quotation" } }
|
||||
|
|
|
@ -75,3 +75,8 @@ C: <nil> nil
|
|||
[ { 3 } ] [ { 1 2 3 } [ { 1 2 } prepend ] undo ] unit-test
|
||||
[ { 1 2 3 } [ { 1 2 } append ] undo ] must-fail
|
||||
[ { 1 2 3 } [ { 2 3 } prepend ] undo ] must-fail
|
||||
|
||||
[ [ sq ] ] [ [ sqrt ] [undo] ] unit-test
|
||||
[ [ sqrt ] ] [ [ sq ] [undo] ] unit-test
|
||||
[ [ not ] ] [ [ not ] [undo] ] unit-test
|
||||
[ { 3 2 1 } ] [ { 1 2 3 } [ reverse ] undo ] unit-test
|
||||
|
|
|
@ -20,6 +20,11 @@ M: fail summary drop "Matching failed" ;
|
|||
|
||||
: define-inverse ( word quot -- ) "inverse" set-word-prop ;
|
||||
|
||||
: define-dual ( word1 word2 -- )
|
||||
2dup swap [ 1quotation define-inverse ] 2bi@ ;
|
||||
|
||||
: define-involution ( word -- ) dup 1quotation define-inverse ;
|
||||
|
||||
: define-math-inverse ( word quot1 quot2 -- )
|
||||
pick 1quotation 3array "math-inverse" set-word-prop ;
|
||||
|
||||
|
@ -129,28 +134,24 @@ MACRO: undo ( quot -- ) [undo] ;
|
|||
|
||||
! Inverse of selected words
|
||||
|
||||
\ swap [ swap ] define-inverse
|
||||
\ swap define-involution
|
||||
\ dup [ [ =/fail ] keep ] define-inverse
|
||||
\ 2dup [ over =/fail over =/fail ] define-inverse
|
||||
\ 3dup [ pick =/fail pick =/fail pick =/fail ] define-inverse
|
||||
\ pick [ [ pick ] dip =/fail ] define-inverse
|
||||
\ tuck [ swapd [ =/fail ] keep ] define-inverse
|
||||
|
||||
\ not [ not ] define-inverse
|
||||
\ not define-involution
|
||||
\ >boolean [ { t f } memq? assure ] define-inverse
|
||||
|
||||
\ tuple>array [ >tuple ] define-inverse
|
||||
\ >tuple [ tuple>array ] define-inverse
|
||||
\ reverse [ reverse ] define-inverse
|
||||
\ tuple>array \ >tuple define-dual
|
||||
\ reverse define-involution
|
||||
|
||||
\ undo 1 [ [ call ] curry ] define-pop-inverse
|
||||
\ map 1 [ [undo] [ over sequence? assure map ] curry ] define-pop-inverse
|
||||
|
||||
\ exp [ log ] define-inverse
|
||||
\ log [ exp ] define-inverse
|
||||
\ not [ not ] define-inverse
|
||||
\ sq [ sqrt ] define-inverse
|
||||
\ sqrt [ sq ] define-inverse
|
||||
\ exp \ log define-dual
|
||||
\ sq \ sqrt define-dual
|
||||
|
||||
ERROR: missing-literal ;
|
||||
|
||||
|
@ -204,8 +205,7 @@ DEFER: _
|
|||
\ first3 [ 3array ] define-inverse
|
||||
\ first4 [ 4array ] define-inverse
|
||||
|
||||
\ prefix [ unclip ] define-inverse
|
||||
\ unclip [ prefix ] define-inverse
|
||||
\ prefix \ unclip define-dual
|
||||
\ suffix [ dup but-last swap peek ] define-inverse
|
||||
|
||||
\ append 1 [ [ ?tail assure ] curry ] define-pop-inverse
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
"\\_<-?[0-9]+\\.[0-9]*\\([eE][+-]?[0-9]+\\)?\\_>")
|
||||
|
||||
(defconst fuel-syntax--bad-string-regex
|
||||
"\"[^\"]*$")
|
||||
"\"\\([^\"]\\|\\\\\"\\)*\n")
|
||||
|
||||
(defconst fuel-syntax--word-definition-regex
|
||||
(fuel-syntax--second-word-regex
|
||||
|
@ -226,7 +226,7 @@
|
|||
;; CHARs:
|
||||
("CHAR: \\(.\\)\\( \\|$\\)" (1 "w"))
|
||||
;; Strings
|
||||
("\\(\"\\)[^\n\r\f]*\\(\"\\)" (1 "\"") (2 "\""))
|
||||
("\\(\"\\)\\([^\n\r\f\\\"]\\|\\\\\"?\\)*\\(\"\\)" (1 "\"") (3 "\""))
|
||||
;; Let and lambda:
|
||||
("\\_<\\(!(\\) .* \\()\\)" (1 "<") (2 ">"))
|
||||
("\\(\\[\\)\\(let\\|wlet\\|let\\*\\)\\( \\|$\\)" (1 "(]"))
|
||||
|
|
Loading…
Reference in New Issue