mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
* Added Monkey2 (extension .monkey2) example This compiles with the most up to date Monkey2 release (V1.1.06). * Sorting example in Monkey2 * Add files via upload * Gui example using the MojoX module
29 lines
457 B
Plaintext
29 lines
457 B
Plaintext
'Showcases use of Lambda functions and Generics.
|
|
|
|
#Import "<std>"
|
|
Using std..
|
|
|
|
Function Main()
|
|
|
|
Local testStack := New Stack< MyObject >
|
|
|
|
For Local n := 1 To 20
|
|
Local newItem := New MyObject
|
|
newItem.depth = Rnd( 0, 100 )
|
|
testStack.Push( newItem )
|
|
Next
|
|
|
|
testStack.Sort( Lambda:Int( x:MyObject,y:MyObject )
|
|
Return x.depth<=>y.depth
|
|
End )
|
|
|
|
For Local n := Eachin testStack
|
|
Print( n.depth )
|
|
Next
|
|
|
|
End
|
|
|
|
|
|
Struct MyObject
|
|
Field depth := 0
|
|
End |