Permalink
Browse files

Implemented missing list_gen() in extopenscad.

  • Loading branch information...
1 parent 4e20328 commit 8ecde3e99e97ca261bf39a700177f67a652c3bbd @colah committed Dec 5, 2012
Showing with 15 additions and 1 deletion.
  1. +15 −1 Graphics/Implicit/ExtOpenScad/Default.hs
View
16 Graphics/Implicit/ExtOpenScad/Default.hs
@@ -85,7 +85,8 @@ defaultPolymorphicFunctions =
(">=", toOObj ((>=) :: -> -> Bool) ),
("<=", toOObj ((<=) :: -> -> Bool) ),
("==", toOObj ((==) :: OVal -> OVal -> Bool) ),
- ("!=", toOObj ((/=) :: OVal -> OVal -> Bool) )
+ ("!=", toOObj ((/=) :: OVal -> OVal -> Bool) ),
+ ("list_gen", toOObj list_gen)
] where
-- Some key functions are written as OVals in optimizations attempts
@@ -182,3 +183,16 @@ defaultPolymorphicFunctions =
errorAsAppropriate name a b = OError
["Can't " ++ name ++ " objects of types " ++ oTypeStr a ++ " and " ++ oTypeStr b ++ "."]
+ list_gen :: [] -> Maybe []
+ list_gen [a,b] = Just [fromIntegral (ceiling a).. fromIntegral (floor b)]
+ list_gen [a, b, c] =
+ let
+ nr = (c-a)/b
+ n = fromIntegral (floor nr)
+ in if nr - n > 0
+ then Just
+ [fromIntegral (ceiling a), fromIntegral (ceiling (a+b)).. fromIntegral (floor (c - b*(nr -n)))]
+ else Just
+ [fromIntegral (ceiling a), fromIntegral (ceiling (a+b)).. fromIntegral (floor c)]
+ list_gen _ = Nothing
+

0 comments on commit 8ecde3e

Please sign in to comment.