Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/Flatten-a-list/PureBasic/flatten-a-list-1.basic
Normal file
22
Task/Flatten-a-list/PureBasic/flatten-a-list-1.basic
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
Structure RCList
|
||||
Value.i
|
||||
List A.RCList()
|
||||
EndStructure
|
||||
|
||||
Procedure Flatten(List A.RCList())
|
||||
ResetList(A())
|
||||
While NextElement(A())
|
||||
With A()
|
||||
If \Value
|
||||
Continue
|
||||
Else
|
||||
ResetList(\A())
|
||||
While NextElement(\A())
|
||||
If \A()\Value: A()\Value=\A()\Value: EndIf
|
||||
Wend
|
||||
EndIf
|
||||
While ListSize(\A()): DeleteElement(\A()): Wend
|
||||
If Not \Value: DeleteElement(A()): EndIf
|
||||
EndWith
|
||||
Wend
|
||||
EndProcedure
|
||||
32
Task/Flatten-a-list/PureBasic/flatten-a-list-2.basic
Normal file
32
Task/Flatten-a-list/PureBasic/flatten-a-list-2.basic
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
;- Set up two lists, one multi dimensional and one 1-D.
|
||||
NewList A.RCList()
|
||||
|
||||
;- Create a deep list
|
||||
With A()
|
||||
AddElement(A()): AddElement(\A()): AddElement(\A()): \A()\Value=1
|
||||
AddElement(A()): A()\Value=2
|
||||
AddElement(A()): AddElement(\A()): \A()\Value=3
|
||||
AddElement(\A()): \A()\Value=4
|
||||
AddElement(A()): AddElement(\A()): \A()\Value=5
|
||||
AddElement(A()): AddElement(\A()): AddElement(\A()): AddElement(\A())
|
||||
AddElement(A()): AddElement(\A()): AddElement(\A()): \A()\Value=6
|
||||
AddElement(A()): A()\Value=7
|
||||
AddElement(A()): A()\Value=8
|
||||
AddElement(A()): AddElement(\A()): AddElement(\A())
|
||||
EndWith
|
||||
|
||||
Flatten(A())
|
||||
|
||||
;- Present the result
|
||||
If OpenConsole()
|
||||
Print("Flatten: [")
|
||||
ForEach A()
|
||||
Print(Str(A()\Value))
|
||||
If ListIndex(A())<(ListSize(A())-1)
|
||||
Print(", ")
|
||||
Else
|
||||
PrintN("]")
|
||||
EndIf
|
||||
Next
|
||||
Print(#CRLF$+"Press ENTER to quit"): Input()
|
||||
EndIf
|
||||
Loading…
Add table
Add a link
Reference in a new issue