Changeset 5387

Show
Ignore:
Timestamp:
07/11/05 04:12:53 (3 years ago)
Author:
putter
svk:copy_cache_prev:
7349
Message:

Finished haskell versions of floor,ceiling,round,truncate. mugwump++. Given the new r5385 Prelude.pm versions, I dropped them in Pugs::Internals. These two need to be syncronized with Emit/PIR.hs.

Location:
src/Pugs
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Prim.hs

    r5384 r5387  
    138138op1 "+"    = op1Numeric id 
    139139op1 "abs"  = op1Numeric abs 
    140 -- op1 "floor" = op1Cast $ op1Roundy floor 
    141 -- op1 "truncate" = op1Cast $ op1Roundy truncate 
    142 -- op1 "ceiling" = op1Cast $ op1Roundy ceiling 
    143 -- op1 "round" =  op1Cast $ op1Roundy round 
     140op1 "Pugs::Internals::truncate" = op1Round truncate 
     141op1 "Pugs::Internals::round"    = op1Round round 
     142op1 "Pugs::Internals::floor"    = op1Round floor 
     143op1 "Pugs::Internals::ceiling"  = op1Round ceiling 
    144144op1 "cos"  = op1Floating cos 
    145145op1 "sin"  = op1Floating sin 
     
    583583    fmap castV (liftIO $ fun val) 
    584584 
    585 {- 
    586 op1Roundy func x 
    587     | VInt x' <- x 
    588     = return x' 
    589     | VRat x' <- x 
    590     = return . VInt $ func x' 
    591     | otherwise = 0 
    592 -} 
    593  
    594585returnList :: [Val] -> Eval Val 
    595586returnList vals = ifListContext 
     
    13571348\\n   Num       spre    +       safe   (Num)\ 
    13581349\\n   Num       pre     abs     safe   (?Num=$_)\ 
    1359 \\n   Int       pre     truncate safe   (?Num=$_)\ 
    1360 \\n   Int       pre     round   safe   (?Num=$_)\ 
    1361 \\n   Int       pre     floor   safe   (?Num=$_)\ 
    1362 \\n   Int       pre     ceiling safe   (?Num=$_)\ 
     1350\\n   Int       pre     Pugs::Internals::truncate safe   (?Num=$_)\ 
     1351\\n   Int       pre     Pugs::Internals::round    safe   (?Num=$_)\ 
     1352\\n   Int       pre     Pugs::Internals::floor    safe   (?Num=$_)\ 
     1353\\n   Int       pre     Pugs::Internals::ceiling safe   (?Num=$_)\ 
    13631354\\n   Num       pre     atan    safe   (Num)\ 
    13641355\\n   Num       pre     atan    safe   (Num, Num)\ 
  • src/Pugs/Prim/Numeric.hs

    r2989 r5387  
    33 
    44module Pugs.Prim.Numeric ( 
    5     op2Numeric, op1Floating, op1Numeric, 
     5    op2Numeric, op1Floating, op1Round, op1Numeric, 
    66    op2Exp, op2Divide, op2Modulus, 
    77) where 
     
    3636    foo <- fromVal v 
    3737    return $ VNum $ f foo 
     38 
     39op1Round :: (Double -> Integer) -> Val -> Eval Val 
     40op1Round f v = do 
     41    return $ VInt $ case v of 
     42       VInt i -> i 
     43       VRat r -> f ((fromRational r)::Double) 
     44       VNum n -> f n 
     45       _      -> 0 
    3846 
    3947op1Numeric :: (forall a. (Num a) => a -> a) -> Val -> Eval Val