Changeset 16526 for src/Pugs/Prim.hs

Show
Ignore:
Timestamp:
05/25/07 23:12:48 (18 months ago)
Author:
moritz
Message:

patch and test cases for zero or negative argument to 'x' and 'xx' operator
postet ond p6l by chas_owens++

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Prim.hs

    r16488 r16526  
    924924    | otherwise         = VStr str 
    925925 
     926perlReplicate :: VInt -> a -> [a] 
     927perlReplicate i a = if i < 0  
     928    then genericReplicate 0 a  
     929    else genericReplicate i a 
     930 
    926931-- |Implementation of 2-arity primitive operators and functions 
    927932op2 :: String -> Val -> Val -> Eval Val 
     
    932937op2 "/"  = op2Divide 
    933938op2 "%"  = op2Modulus 
    934 op2 "x"  = op2Cast (\x y -> VStr . concat $ (y :: VInt) `genericReplicate` x) 
    935 op2 "xx" = op2Cast (\x y -> VList . concat $ (y :: VInt) `genericReplicate` x) 
     939op2 "x"  = op2Cast (\x y -> VStr . concat $ (y :: VInt) `perlReplicate` x) 
     940op2 "xx" = op2Cast (\x y -> VList . concat $ (y :: VInt) `perlReplicate` x) 
    936941op2 "+&" = op2Int (.&.) 
    937942op2 "+<" = op2Int shiftL