Last active
September 2, 2017 04:21
-
-
Save davidkellis/e1b9b5e6e406a47dfc0744114b6a77ca to your computer and use it in GitHub Desktop.
interfaces extreme 1
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
| interface Enumerable T for E { | |
| fn each(E, T -> Unit) -> Unit | |
| } | |
| impl Enumerable T for Array T { | |
| fn each(array: Array T, f: T -> Unit) -> Unit { ... } | |
| } | |
| impl Enumerable T for I : Iterator T { | |
| fn each(it: I, visit: T -> Unit) = ... | |
| } | |
| impl Enumerable T for Iterator T { | |
| fn each(it: Iterator T, visit: T -> Unit) = ... | |
| } | |
| KeyIterator = impl Enumerable K for Map K V { | |
| fn each(m: Map K V, visit: K -> Unit) -> Unit { ... } | |
| } | |
| ValueIterator = impl Enumerable V for Map K V { | |
| fn each(m: Map K V, visit: V -> Unit) -> Unit { ... } | |
| } | |
| impl Enumerable (K,V) for Map K V | |
| fn each(map: Map K V, f: ( (K,V) ) -> Unit) -> Unit { ... } | |
| } | |
| interface Iterator T for I { | |
| fn has_next?(I) -> Bool | |
| fn next(I) -> Option T | |
| } | |
| interface Mappable for M._ { | |
| fn map[A,B](m: M A, convert: A -> B) -> M B | |
| } | |
| impl Mappable for Array { | |
| fn map(a: Array A, convert: A -> B) -> Array B | |
| } | |
| impl Mappable for Iterator { | |
| fn map(a: Iterator T, convert: T -> B) -> Array B | |
| } | |
| KeyMapper = impl Mappable for Map _ V { | |
| fn map(m: Map K V, convert: K -> K2) -> Map K2 V { ... } | |
| } | |
| ValueMapper = impl Mappable for Map K _ { | |
| fn map(m: Map K V, convert: V -> W) -> Map K W { ... } | |
| } | |
| iterators = Array[Iterator Int](Array(1,2,3), List(4,5,6), Range(10, 20)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment