]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/isequences/ops/multiply/multiply.factor
Fix Windows bootstrap
[factor.git] / unmaintained / isequences / ops / multiply / multiply.factor
1 ! Copyright (C) 2007 Robbert van Dalen.
2 ! See http://factorcode.org/license.txt for BSD license.
3
4 IN: isequences.ops.multiply
5 USING: generic kernel math math.functions sequences
6 isequences.interface isequences.base ;
7
8 : _*g++ ( n s -- s )
9     swap i-length dup zero?
10     [ 2drop 0 ]
11     [ dup odd? [ over ] [ 0 ] if -rot 2/ swap _*g++ dup ++ ++ ]
12     if ;
13
14 : _*g+- ( n s -- s ) -- _* -- ; inline
15
16 : _*g-+ ( n s -- s ) swap -- swap _* ; inline
17
18 : _*g-- ( n s -- s ) [ -- ] 2apply _* ; inline
19
20 : _*g ( n s -- s )
21     2dup [ neg? ] 2apply [ [ _*g-- ] [ _*g+- ] if ]
22     [ [ _*g-+ ] [ _*g++ ] if ] if ; inline
23
24 M: object _* _*g ;
25 M: integer _* swap i-length abs * ;
26