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
// http://en.wikipedia.org/wiki/Bridge_pattern | |
trait DrawingAPI { | |
def drawCircle(x:Double, y: Double, radius:Double) | |
} | |
class DrawingAPI1 extends DrawingAPI { | |
override def drawCircle(x: Double, y: Double, radius: Double) = { | |
printf("API1.circle at %f:%f radius %f\n", x, y, radius) | |
} |
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
trait ProductPrice { | |
def price: Int | |
} | |
class Product { | |
var cost = 500 | |
} | |
class ProductDelegationAdapter extends ProductPrice { | |
private var product = new Product |
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
// http://en.wikipedia.org/wiki/Composite_pattern | |
trait Graphic { | |
def print | |
} | |
class CompositeGraphic extends Graphic { | |
private var mChildGraphics = List[Graphic]() | |
override def print = { |
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
// http://en.wikipedia.org/wiki/Decorator_pattern | |
trait Coffee { | |
def cost:Double | |
def ingredients: String | |
} | |
class SimpleCoffee extends Coffee { | |
override def cost = 1 | |
override def ingredients = "Coffee" |
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
(use 'clojure.set) | |
(def middle-cols 5) | |
(def max-col (inc middle-cols)) | |
(def max-row 2) | |
(defn row [point] (first point)) | |
(defn col [point] (second point)) |
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
val id = "ABCD" //> id : String = ABCD | |
val tl = "BADC" //> tl : String = BADC | |
val tm = "DCBA" //> tm : String = DCBA | |
val tn = "CDAB" //> tn : String = CDAB | |
val a1 = "ACDB" //> a1 : String = ACDB | |
val a2 = "ADBC" //> a2 : String = ADBC | |
val b1 = "DBAC" //> b1 : String = DBAC | |
val b2 = "CBDA" //> b2 : String = CBDA | |
val c1 = "BDCA" //> c1 : String = BDCA | |
val c2 = "DACB" //> c2 : String = DACB |
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
package javaee.util.jsf.phaselistener; | |
import java.util.Map; | |
import javax.faces.component.UIViewRoot; | |
import javax.faces.event.PhaseEvent; | |
import javax.faces.event.PhaseId; | |
import javax.faces.event.PhaseListener; | |
import javax.servlet.http.HttpSession; |
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
module Queue | |
abstract sig Node { next : lone Node } | |
abstract sig Queue { root : lone Node } | |
fact noCycle { no n : Node | n in n.^next } | |
fact noReflexive { no n : Node | n = n.next } | |
fact allNodeInAQueue { | |
all n : Node | some q : Queue | n in q.root.*next | |
} |
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
// 「形式手法入門」P157 「6.2.5 イベント駆動スタイル」 | |
open util/ordering [Time] | |
open util/natural | |
sig Time{} | |
sig State { | |
a, b, c, n : Natural one -> Time, | |
d : Natural | |
}{ |
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
! 133 is Windows key | |
keycode 133 = Zenkaku_Hankaku Kanji Zenkaku_Hankaku Kanji | |
! 修飾子マップ mod4 から Win キーのコードを削除 | |
remove mod4 = Super_L | |
! 101 is katakana_hiragana key | |
keycode 101 = Alt_R Meta_R Alt_R Meta_R | |
remove Control = Control_L | |
remove Control = Control_R |