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 | |
/** | |
* This gives a fatal error | |
*/ | |
class AbsTest { | |
abstract public function saySomething( $something ); | |
public function saySomething( $something ) { | |
echo "{$something}\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
<?php | |
$fibonacci = function( $n ) use ( &$fibonacci ) { | |
return ( $n < 2 ) ? $n : ( $fibonacci( $n - 1 ) + $fibonacci( $n - 2 ) ); | |
}; | |
echo $fibonacci(4); // Outputs "3" (0,1,1,2,3) |
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
;; rgantt's solution to Fibonacci Sequence | |
;; https://4clojure.com/problem/26 | |
(fn[l] | |
(map | |
(fn fib[n] (if (<= n 1) 1 (+ (fib (- n 1)) (fib (- n 2))))) | |
(range l)) | |
) |
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
/** | |
* visitedSoFar contains all nodes that have been traversed | |
* bestPathSoFar should be populated with only the subpath of visitedSoFar that contains no dead ends | |
*/ | |
for( int j = 0; j < visitedSoFar.size(); j++ ) { | |
for( int i = visitedSoFar.size() - 1; i > j; i-- ) { | |
if( visitedSoFar.get( i ).equals( visitedSoFar.get( j ) ) ) { | |
j = i; | |
} |
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 | |
$count = 0; | |
function increase_count() { | |
global $count; | |
$count++; | |
} | |
increase_count(); | |
echo $count; |
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 | |
function profile( $message, $closure ) { | |
$start = microtime( true ); | |
$closure( $start ); | |
$duration = ( microtime( true ) - $start ); | |
return "{$message} {$duration}\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
# run index.html through erb | |
compile '/' do | |
filter :erb | |
layout 'page' | |
end | |
# run the articles through textile | |
compile '/articles/*' do | |
filter :redcloth | |
layout 'article' |
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 sextile { | |
protected $textile; | |
public function TextileThis( $text, $lite = '', $encode = '', $noimage = '', $strict = '', $rel = '' ) { | |
return $this->textile->TextileThis( $this->handle_latex( $text ), $lite, $encode, $noimage, $strict, $rel ); | |
} | |
/** | |
* Spoof interface compatibility |
NewerOlder