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
<?php | |
class Base | |
{ | |
private $x; | |
public function getX() | |
{ | |
return $this->x; | |
} |
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
var M = function() { }; | |
M.prototype = { | |
m : function() { return 42 } | |
}; | |
var inst = new M(); | |
inst.f = function() { return 42 }; |
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
// Recursive version | |
function isMeasurable(target, weights) | |
{ | |
if (weights.length == 0) | |
return target == 0; | |
var first = weights.shift(); | |
return | |
isMeasurable(target-first, weights) || |
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
data Tree t = EmptyTree | |
| Node t (Tree t) (Tree t) | |
deriving Show | |
nivel :: Int -> Int | |
nivel n = nivel' n 0 | |
where | |
nivel' 0 _ = 0 | |
nivel' 1 x = x | |
nivel' n x = nivel' (n `div` 2) (x + 1) |
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
firstNonRep :: String -> Maybe Char | |
firstNonRep cs = fmap fst $ find (\(c, n) -> n == 1) $ foldl count [] cs | |
where | |
count [] c = [(c, 1)] | |
count (p@(c', n) : ps) c | c == c' = (c', n+1) : ps | |
| otherwise = p : count ps c |