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
<?php | |
$tweet = 'Detta är ett #test för min blog... #ignoreme #lördag #måla #mäktigt #coolt #åsa-nisse #()lol()'; | |
$pattern = '/#(\pL+)/'; | |
$replacement = '<a href="#$1">$0</a>'; | |
echo preg_replace($pattern, $replacement, $tweet); |
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
Att stödja en regeringen är inte samma sak som att sitta i regeringen. Flyborg påstod att MP var "i regeringsställning", vilket betyder att man verkligen sitter i regeringen. |
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
<?php | |
abstract class Loader | |
{ | |
abstract public function load(); | |
} | |
class PaymentLoader extends Loader | |
{ | |
protected $id; |
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 |
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 Data.List(find) | |
findSum :: Num a => a -> [a] -> Bool | |
findSum s ns = find (sumIs s) (pairs ns) | |
where | |
sumIs :: Num a => a -> (a, a) -> Bool | |
sumIs s (x, y) = x+y == s | |
pairs :: [a] -> [(a, a)] | |
pairs [] = [] |
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
{-# LANGUAGE GADTs, EmptyDataDecls, ExistentialQuantification #-} | |
module RBTree where | |
-- Node color | |
data Red | |
data Black | |
-- Node depth |
OlderNewer