This file contains 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
// first version - code demonstrating the basic idea. | |
// see below for a fuller-featured implementation | |
import std.string; | |
import std.range; | |
import std.stdio; | |
/* A very simple string templating system. Placeholders of the form | |
* %{variable} are replaced by the corresponding variable in the current | |
* scope. |
This file contains 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 Dict | |
side = 30 | |
n = 15 | |
x0 = side * n | |
-- coordinates | |
toScreen (x, y) = (side * x - x0, side * (n - y)) | |
fromScreen (x, y) = (div (x + x0) side, n - div y side) |
This file contains 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 Dict | |
import Keyboard | |
import Char | |
side = 30 | |
n = 15 | |
x0 = side * n | |
-- model |
This file contains 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
class PurchaseApprover | |
# Implements the chain of responsibility pattern. Does not know anything | |
# about the approval process, merely whether the current handler can approve | |
# the request, or must pass it to a successor. | |
attr_reader :successor | |
def initialize successor | |
@successor = successor | |
end |
This file contains 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
(use iup) | |
(define (nlines self) 8) | |
(define (ncols self) 8) | |
(define (height self line) 50) | |
(define (width self col) 50) | |
(define (draw self i j xmin xmax ymin ymax canvas) 'default) | |
(define dlg |
This file contains 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
// WTF: Is there really no Gdk.RGBA constructor? No docs either! | |
let mutable color = Gdk.RGBA () | |
color.Red <- 1.0 | |
color.Green <- 1.0 | |
color.Blue <- 0.8 | |
color.Alpha <- 1.0 | |
current.OverrideBackgroundColor(StateFlags.Normal, color) |