langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
32
Task/Flatten-a-list/VBScript/flatten-a-list-1.vbscript
Normal file
32
Task/Flatten-a-list/VBScript/flatten-a-list-1.vbscript
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
class flattener
|
||||
dim separator
|
||||
|
||||
sub class_initialize
|
||||
separator = ","
|
||||
end sub
|
||||
|
||||
private function makeflat( a )
|
||||
dim i
|
||||
dim res
|
||||
for i = lbound( a ) to ubound( a )
|
||||
if isarray( a( i ) ) then
|
||||
res = res & makeflat( a( i ) )
|
||||
else
|
||||
res = res & a( i ) & separator
|
||||
end if
|
||||
next
|
||||
makeflat = res
|
||||
end function
|
||||
|
||||
public function flatten( a )
|
||||
dim res
|
||||
res = makeflat( a )
|
||||
res = left( res, len( res ) - len(separator))
|
||||
res = split( res, separator )
|
||||
flatten = res
|
||||
end function
|
||||
|
||||
public property let itemSeparator( c )
|
||||
separator = c
|
||||
end property
|
||||
end class
|
||||
4
Task/Flatten-a-list/VBScript/flatten-a-list-2.vbscript
Normal file
4
Task/Flatten-a-list/VBScript/flatten-a-list-2.vbscript
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
dim flat
|
||||
set flat = new flattener
|
||||
flat.itemSeparator = "~"
|
||||
wscript.echo join( flat.flatten( array( array( 1 ),2,array(array(3,4),5),array(array(array())),array(array(array(6))),7,8,array())), "!")
|
||||
1
Task/Flatten-a-list/VBScript/flatten-a-list-3.vbscript
Normal file
1
Task/Flatten-a-list/VBScript/flatten-a-list-3.vbscript
Normal file
|
|
@ -0,0 +1 @@
|
|||
1!2!3!4!5!6!7!8
|
||||
Loading…
Add table
Add a link
Reference in a new issue