File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,17 @@ exports.range = function (start) {
16
16
} ;
17
17
} ;
18
18
19
+ exports . replicate = function ( count ) {
20
+ return function ( value ) {
21
+ var result = [ ] ;
22
+ var n = 0 ;
23
+ for ( var i = 0 ; i < count ; i ++ ) {
24
+ result [ n ++ ] = value ;
25
+ }
26
+ return result ;
27
+ } ;
28
+ } ;
29
+
19
30
exports . fromFoldableImpl = ( function ( ) {
20
31
// jshint maxparams: 2
21
32
function Cons ( head , tail ) {
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ module Data.Array
32
32
, toUnfoldable
33
33
, singleton
34
34
, (..), range
35
+ , replicate
35
36
, some
36
37
, many
37
38
@@ -141,6 +142,9 @@ singleton a = [a]
141
142
-- | Create an array containing a range of integers, including both endpoints.
142
143
foreign import range :: Int -> Int -> Array Int
143
144
145
+ -- | Create an array containing a value repeated the specified number of times.
146
+ foreign import replicate :: forall a . Int -> a -> Array a
147
+
144
148
-- | An infix synonym for `range`.
145
149
infix 8 range as ..
146
150
You can’t perform that action at this time.
0 commit comments