tfwh-0.3.7.0

Safe HaskellSafe
LanguageHaskell2010

TFwH.Chap03.ExB

Description

第3章 練習問題 B

  • (^^) はどのように定義するか
  import Prelude hiding ((^^))

  (^^) :: (Fractional a, Integral b) => a -> b -> a
  x ^^ p = if p < 0 then recip (x ^ abs p) else x ^ p
  

Synopsis

Documentation

(^^) :: (Fractional a, Integral b) => a -> b -> a Source #

>>> 2.5 ^^ 2
6.25
>>> 2.5 ^^ (-2)
0.16