Skip to content

Commit e7cb46c

Browse files
committed
Use pow from Data.Int
1 parent a251fde commit e7cb46c

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"devDependencies": {
2424
"purescript-assert": "^2.0.0",
2525
"purescript-console": "^2.0.0",
26-
"purescript-integers": "^2.0.0",
26+
"purescript-integers": "^2.1.0",
2727
"purescript-math": "^2.0.0",
2828
"purescript-unsafe-coerce": "^2.0.0"
2929
}

test/Main.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,3 @@ exports.arrayReplicate = function (n) {
1717
return result;
1818
};
1919
};
20-
21-
exports.intPow = function (x) {
22-
return function (y) {
23-
return Math.pow(x,y) | 0;
24-
};
25-
};

test/Main.purs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Data.Bifunctor (class Bifunctor, bimap)
1010
import Data.Bitraversable (class Bitraversable, bisequenceDefault, bitraverse, bisequence, bitraverseDefault)
1111
import Data.Foldable (class Foldable, foldl, foldr, foldMap, foldrDefault, foldlDefault, foldMapDefaultR, foldMapDefaultL, minimumBy, minimum, maximumBy, maximum, find, findMap)
1212
import Data.Function (on)
13-
import Data.Int (toNumber)
13+
import Data.Int as Int
1414
import Data.Maybe (Maybe(..))
1515
import Data.Monoid.Additive (Additive(..))
1616
import Data.Newtype (unwrap)
@@ -24,8 +24,6 @@ import Test.Assert (ASSERT, assert, assert')
2424
foreign import arrayFrom1UpTo :: Int -> Array Int
2525
foreign import arrayReplicate :: forall a. Int -> a -> Array a
2626

27-
foreign import intPow :: Int -> Int -> Int
28-
2927
foldableLength :: forall f a. Foldable f => f a -> Int
3028
foldableLength = unwrap <<< foldMap (const (Additive 1))
3129

@@ -106,7 +104,7 @@ main = do
106104
log "Test maximumBy"
107105
assert $
108106
maximumBy (compare `on` abs)
109-
(map (negate <<< toNumber) (arrayFrom1UpTo 10))
107+
(map (negate <<< Int.toNumber) (arrayFrom1UpTo 10))
110108
== Just (-10.0)
111109

112110
log "Test minimum"
@@ -115,7 +113,7 @@ main = do
115113
log "Test minimumBy"
116114
assert $
117115
minimumBy (compare `on` abs)
118-
(map (negate <<< toNumber) (arrayFrom1UpTo 10))
116+
(map (negate <<< Int.toNumber) (arrayFrom1UpTo 10))
119117
== Just (-1.0)
120118

121119
log "All done!"
@@ -145,7 +143,7 @@ testTraversableFWith f n = do
145143
assert' "traverse pure == pure (Array)" $ traverse pure dat == [dat]
146144

147145
when (len <= 10) do
148-
result <- deferEff \_ -> traverse (\x -> [x,x]) dat == arrayReplicate (intPow 2 len) dat
146+
result <- deferEff \_ -> traverse (\x -> [x,x]) dat == arrayReplicate (Int.pow 2 len) dat
149147
assert' "traverse with Array as underlying applicative" result
150148

151149
assert' "traverse (const Nothing) == const Nothing" $

0 commit comments

Comments
 (0)