This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[crate_id = "mu1"]; | |
| #[crate_type = "bin"]; | |
| use std::cast::transmute; | |
| use std::cell::RefCell; | |
| use std::libc::size_t; | |
| use std::rc::{Rc, Weak}; | |
| static ErrAlreadyParented: &'static str = "Morph already has a parent."; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| proc doThings(spuds: var int): int = | |
| spuds = 24 | |
| return 99 | |
| suite "broken": | |
| test "count the spuds": | |
| var spuds = 0 | |
| check doThings(spuds) == 99 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import | |
| rectangle | |
| type | |
| MaxRectPacker* [T] = object | |
| initialWidth, initialHeight: T | |
| freeGeometry: seq[Rectangle[T]] | |
| proc TryGet* [T](self: var MaxRectPacker[T]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type | |
| RPizza = ref Pizza | |
| Pizza = object | |
| Backref: RPizza | |
| proc NoPizza(self: RPizza) = | |
| debugEcho "Pizza eaten by ghosts." | |
| proc main() = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Something kind of like this; replicating wxWidgets style event mapping: | |
| ImplHandleEvent(MyEventHandler): | |
| On(CommandTriggeredEvent, self.OnCommand) | |
| On MorphClosedEvent, self.OnClosed | |
| On SomethingEvent do: | |
| debugEcho "Something else entirely..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This works | |
| macro MakeIntoEvent* (etype: typedesc): stmt = | |
| let uid = NextEventTypeUID | |
| Inc(NextEventTypeUID) | |
| debugEcho "DUMP ID #", uid, ": ", repr(etype) | |
| result = quote do: | |
| proc GetEventTypeUid* ( | |
| self: typedesc[`etype`]): EventTypeUid {.inline.} = | |
| let x = `uid` | |
| return x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type | |
| CommandEvent = object | |
| Actions = enum | |
| AMeep, | |
| APacake | |
| MakeIntoEvent CommandEvent | |
| when isMainModule: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type | |
| FHandler = proc(x) {.closure.} | |
| Receivers = seq[FHandler] | |
| Beans = object | |
| floor: bool | |
| proc Emit(self: Receivers; x: int) = | |
| for e in items(self): | |
| e(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [] | |
| digit-nz: charset "123456789" | |
| digit: append copy digit-nz #"0" | |
| hex: append copy digit "abcdefABCDEF" | |
| sign: charset "+-" | |
| exponent-e: charset "eE" | |
| dquot: #"^"" | |
| exponent: [ exponent-e opt sign some digit ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [] | |
| random/seed 1337 | |
| ; produces a series of chromosomes within [0, dna] of each supplied maximum | |
| make-dna-strand: func[dna | |
| /local dna-length result][ | |
| dna-length: length? dna | |
| result: make block! dna-length | |
| foreach chromosome dna [ |
OlderNewer