How can you make a growing collection in F# -
is there collection type in f# has "append" method, such can add element collection such:
(pseudo code)
let list = [1,2,3,4] list.append( 5 ) print list
result : 1,2,3,4,5
basically need collection can grow @ run time, cant assume size be. couldn't find way list or array in f#
update: dont want create new list/array every time happening many times. want append existing collection. need use same name/symbol collection. f# doesn't allow me redeclare or on write collection, wouldnt work:
let = [1,2,3] let = a.append 4 or <- array.appen 4
you can use resizearray
:
let list = resizearray([1;2;3;4]) list.add( 5 )
Comments
Post a Comment