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) {
1616 } ;
1717} ;
1818
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+
1930exports . fromFoldableImpl = ( function ( ) {
2031 // jshint maxparams: 2
2132 function Cons ( head , tail ) {
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ module Data.Array
3232 , toUnfoldable
3333 , singleton
3434 , (..), range
35+ , replicate
3536 , some
3637 , many
3738
@@ -141,6 +142,9 @@ singleton a = [a]
141142-- | Create an array containing a range of integers, including both endpoints.
142143foreign import range :: Int -> Int -> Array Int
143144
145+ -- | Create an array containing a value repeated the specified number of times.
146+ foreign import replicate :: forall a . Int -> a -> Array a
147+
144148-- | An infix synonym for `range`.
145149infix 8 range as ..
146150
You can’t perform that action at this time.
0 commit comments