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 createGrid = function (rows, cols) { | |
var str = "", | |
odd = "o", | |
even = "#"; | |
for (var row = 0; row < rows; row++) { | |
for (var col = 0; col < cols; col++) { | |
if ((row + col) % 2 === 0) { | |
str += even; | |
} else { | |
str += odd; |
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 | |
interface Shape { | |
public function draw(); | |
} | |
class Rectangle implements Shape { | |
public function draw() { | |
echo "Shape: Rectangle\r\n"; | |
} |
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
def fibo(): | |
a, b = 0, 1 | |
while True: | |
yield a | |
a, b = b, a + b | |
# usage | |
f = fibo() | |
f.next() | |
... |
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 | |
interface Dog | |
{ | |
public function speak (); | |
} | |
class Poodle implements Dog | |
{ | |
public function speak() |
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 | |
// Command | |
interface Order { | |
public function execute(); | |
} | |
// Receiver Class | |
class Stock { | |
NewerOlder