! Copyright (C) 2007, 2008 Daniel Ehrenberg
! Portions copyright (C) 2009 Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs classes.tuple definitions
-generalizations generic generic.standard hashtables kernel
-lexer make math parser generic.parser sequences sets slots
-words words.symbol fry ;
+USING: accessors arrays assocs classes.tuple definitions generic
+generic.standard hashtables kernel lexer make math parser
+generic.parser sequences sets slots words words.symbol fry ;
IN: delegate
: protocol-words ( protocol -- words )
: consult-method ( word class quot -- )
[ drop swap first create-method-in ]
- [ nip [ , dup second , \ ndip , first , ] [ ] make ] 3bi
+ [ nip [ swap [ second [ [ dip ] curry ] times % ] [ first , ] bi ] [ ] make ] 3bi
define ;
: change-word-prop ( word prop quot -- )
! Cavazos, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel sequences sequences.private math combinators
-macros quotations fry stack-checker.transforms effects ;
+macros quotations fry effects ;
IN: generalizations
<<
: nappend-as ( n exemplar -- seq )
[ narray concat ] dip like ; inline
-: nappend ( n -- seq ) narray concat ; inline
-
-: nths-quot ( indices -- quot )
- [ [ '[ _ swap nth ] ] map ] [ length ] bi
- '[ _ cleave _ narray ] ;
-
-\ shuffle [
- shuffle-mapping nths-quot
-] 1 define-transform
\ No newline at end of file
+: nappend ( n -- seq ) narray concat ; inline
\ No newline at end of file
namespaces make quotations assocs combinators classes.tuple
classes.tuple.private effects summary hashtables classes generic
sets definitions generic.standard slots.private continuations locals
-stack-checker.backend stack-checker.state stack-checker.visitor
-stack-checker.errors stack-checker.values
+generalizations stack-checker.backend stack-checker.state
+stack-checker.visitor stack-checker.errors stack-checker.values
stack-checker.recursive-state ;
IN: stack-checker.transforms
\ memq? [
dup sequence? [ memq-quot ] [ drop f ] if
] 1 define-transform
+
+! Shuffling
+: nths-quot ( indices -- quot )
+ [ [ '[ _ swap nth ] ] map ] [ length ] bi
+ '[ _ cleave _ narray ] ;
+
+\ shuffle [
+ shuffle-mapping nths-quot
+] 1 define-transform
\ No newline at end of file