File tree 1 file changed +6
-0
lines changed
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -470,12 +470,18 @@ numMagnitude badArgList = throwError $ NumArgs (Just 1) badArgList
470
470
-- | Retrieve real part of a complex number
471
471
numRealPart :: [LispVal ] -> ThrowsError LispVal
472
472
numRealPart [(Complex c)] = return $ Float $ realPart c
473
+ numRealPart [n@ (Float _)] = return n
474
+ numRealPart [n@ (Rational _)] = return n
475
+ numRealPart [n@ (Number _)] = return n
473
476
numRealPart [x] = throwError $ TypeMismatch " complex number" x
474
477
numRealPart badArgList = throwError $ NumArgs (Just 1 ) badArgList
475
478
476
479
-- | Retrieve imaginary part of a complex number
477
480
numImagPart :: [LispVal ] -> ThrowsError LispVal
478
481
numImagPart [(Complex c)] = return $ Float $ imagPart c
482
+ numImagPart [(Float _)] = return $ Number 0
483
+ numImagPart [(Rational _)] = return $ Number 0
484
+ numImagPart [(Number _)] = return $ Number 0
479
485
numImagPart [x] = throwError $ TypeMismatch " complex number" x
480
486
numImagPart badArgList = throwError $ NumArgs (Just 1 ) badArgList
481
487
You can’t perform that action at this time.
0 commit comments