Paste: Still no idea about cond

Author: Leonidas
Mode: factor
Date: Wed, 24 Feb 2010 21:58:40
Plain Text |
: subtail ( seq n -- seq ) short tail ;
: subtail* ( seq n -- seq ) short tail* ;

: unclip-nlast ( seq n -- seq seq ) 2dup subtail* [ subtail ] dip ;

: apply-rules ( seq -- seq ? ) {
  { [ dup 2 unclip-nlast { right left } = ] [ nip { left right } append t ] }
  [ f ]
} cond ;

Annotation: Leonidas learned cond

Author: Leonidas
Mode: factor
Date: Wed, 24 Feb 2010 22:11:32
Plain Text |
: subtail ( seq n -- seq ) short tail ;
: subtail* ( seq n -- seq ) short tail* ;

: unclip-nlast ( seq n -- seq seq ) 2dup subtail* [ subtail ] dip ;

: apply-rules ( seq -- seq ? ) {
  { [ dup 2 unclip-nlast { right left } = ] [ nip { left right } append t ] }
  [ drop f ]
} cond ;

New Annotation

Summary:
Author:
Mode:
Body: