1 ! Copyright (C) 2011 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: combinators.short-circuit kernel math math.order
7 ERROR: invalid-percent x ;
9 : check-percent ( x -- x )
10 dup 0 1 between? [ throw-invalid-percent ] unless ;
12 ERROR: invalid-length x ;
14 : check-length ( x -- x )
15 dup { [ 0 > ] [ integer? ] } 1&& [ throw-invalid-length ] unless ;
17 : (make-progress-bar) ( percent len completed-ch pending-ch -- string )
18 [ [ * >integer ] keep over - ] 2dip
19 [ <repetition> ] bi-curry@ bi* "" append-as ;
21 : make-progress-bar ( percent length -- string )
22 [ check-percent ] [ check-length ] bi*
23 CHAR: = CHAR: - (make-progress-bar) ;