mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Added a few Monkey2 examples (#3811)
* 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
This commit is contained in:
committed by
Colin Seymour
parent
db1d4f7893
commit
a4e6fc78c8
29
samples/Monkey/sorting.monkey2
Normal file
29
samples/Monkey/sorting.monkey2
Normal file
@@ -0,0 +1,29 @@
|
||||
'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
|
||||
Reference in New Issue
Block a user