Paste: short circuit "and"

Author: tylerg
Mode: factor
Date: Thu, 12 Mar 2009 20:09:38
Plain Text |
Sometimes you want don't want both your expressions to be evaluated if the first one fails

arbitrary example:

0 [ 0 = not ] [ 2 swap / 5 > ] bi and

=> division by zero error

so instead we will use andq

0 [ 0 = not ] [ 2 swap / 5 < ] bi-curry andq

=> f

: andq ( quot quot -- bool )
  [ call ] dip [ f ] if ;

New Annotation

Summary:
Author:
Mode:
Body: