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
| class MyEq a where | |
| equalsTo :: a -> a -> Bool | |
| equalsTo x y = not (notEqualsTo x y) | |
| notEqualsTo :: a -> a -> Bool | |
| notEqualsTo x y = not (equalsTo x y) | |
| instance MyEq Integer where | |
| equalsTo x y = x == y | |
| main = do putStrLn (show $ notEqualsTo (1::Integer) (2::Integer)) |
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
| protocol Eq { | |
| typealias A = Self | |
| func equalsTo(a: A) -> Bool | |
| func notEqualsTo(a: A) -> Bool | |
| } | |
| extension Eq { | |
| func equalsTo(a: A) -> Bool { return !self.notEqualsTo(a) } | |
| func notEqualsTo(a: A) -> Bool { return self.equalsTo(a) } | |
| } |
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
| var x: X? = X() | |
| // leaks if closure1 is called, and it does not capture self by [unowned self] | |
| //x!.closure1() | |
| // if capture self, crashes because x is deallocated befor closure is called. | |
| x!.method() | |
| x = nil | |
| extension NSTimer { |
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
| // from Swiftz | |
| public class K1<A> { public init() {} } | |
| protocol Monad { | |
| typealias A | |
| typealias B | |
| typealias FB = K1<B> | |
| func bind(A -> FB) -> FB; | |
| static func ret(A) -> Self | |
| } |
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
| // node --harmony timeout-seq.js | |
| [3,5,10] | |
| .map(function(sec) { return sec * 1000; }) | |
| .map(function(duration) { | |
| return function task(resolve) { | |
| setTimeout(function() { | |
| console.log(duration); | |
| resolve(); | |
| }, duration); |
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
| //include | |
| //------------------------------------------ | |
| #include <vector> | |
| #include <list> | |
| #include <map> | |
| #include <set> | |
| #include <deque> | |
| #include <stack> | |
| #include <bitset> | |
| #include <algorithm> |
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
| <html> | |
| <head> | |
| <script type="text/javascript" | |
| src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
| </head> | |
| <body> | |
| <script type="text/javascript" src="js/index.js"></script> | |
| </body> | |
| </html> |
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 strict"; | |
| /****** Library START ******/ | |
| var hike = function() { | |
| var user_fn, i, len, rule_strs, rule_parsed, | |
| rule = {}, /* arg length -> [arg name] */ | |
| _arguments = Array.prototype.slice.call(arguments); | |
| user_fn = _arguments.pop(); |
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
| var graph1 = { | |
| vertex: ["1","2","3"], | |
| edge: [, | |
| /* vertex1, vertex2, weight */ | |
| ["1", "2", 4], | |
| ["1", "3", 7], | |
| ["2", "3", 1] | |
| ] | |
| }, | |
| graph2 = { |
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
| // 71 ms for input:1000000 | |
| var prime_procedural = function(end) { | |
| var i,j,n; | |
| var sieve = [], | |
| primes = []; | |
| sieve[0]=false; | |
| for(i=1; i<end+1; i+=1) { | |
| sieve[i]=true; |