Paste: 2xbi

Author: dharmatech
Mode: factor
Date: Sat, 15 Nov 2008 14:12:21
Plain Text |
: consume-double ( quot -- quot )
  dup infer in>>
  {
    { [ dup 0 = ] [ drop [ drop drop ] prepose ] }
    { [ dup 1 = ] [ drop [ nip       ] prepose ] }
    { [ dup 2 = ] [ drop                       ] }
    { [ t       ] [ drop "consume-double: must consume 0, 1, or 2" throw ] }
  }
  cond ;

: [2xbi] ( a b -- quot ) [ consume-double ] bi@ [ 2bi ] curry curry ;

MACRO: 2xbi ( a b -- quot ) [2xbi] ;

New Annotation

Summary:
Author:
Mode:
Body: