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
number = function(x) { return getType(x) == 'number'; } | |
string = function(x) { return getType(x) == 'string'; } | |
//combinators | |
function or() { | |
var len = arguments.length; | |
var args = arguments; | |
return function(x) { | |
for(var i = 0; i < len; ++i) { | |
if(validate(args[i], x)) return true;//satisfy at least one condition |
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
#include <iostream> | |
template<typename Scalar> | |
class DualNumber | |
{ | |
public: | |
inline DualNumber(const Scalar& realPart, const Scalar& dualPart = Scalar()) | |
:mReal(realPart) | |
,mDual(dualPart) | |
{ |
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
(load "yo_dawg.rkt") | |
(define test-fib | |
'[(define (fib n) | |
(if (<= n 2) | |
1 | |
(+ (fib (- n 1)) (fib (- n 2))))) | |
(fib 6)]) | |
(evaluate-block test-fib) |
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
#include <iostream> | |
#include <functional> | |
template<typename ReturnType, typename Arg1> | |
struct tail_call_result | |
{ | |
template<typename FuncType> | |
inline tail_call_result(FuncType func, Arg1 arg) | |
:func(func) | |
,argument(arg) |
NewerOlder