repeat

spir denis.spir at gmail.com
Tue Jan 18 04:33:53 PST 2011


On 01/18/2011 01:10 PM, Aziz K. wrote:
> I would prefer it to work like this:
>
> repeat("abc", 3) -> "abcabcabc"
> repeat(["abc"], 3) -> ["abc","abc","abc"]
> repeat([1,2,3], 3) -> [1,2,3,1,2,3,1,2,3]

I find this consistent in that the operation keeps the nesting level 
constant. But then we need a good name for an operation that nests into 
a higher-level array ;-) What about
	arrayOf (T) (T something, uint count=1)
?

arrayOf("abc", 3)   -> ["abc","abc","abc"]
arrayOf(["abc"], 3) -> [["abc"],["abc"],["abc"]]
arrayOf([1,2,3], 3) -> [[1,2,3],[1,2,3],[1,2,3]]


Denis
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d mailing list