#include <iostream> #include <typeinfo>
template<class X> class Reduced { public: typedef X value; };
template<class X,class Y> class cons : public Reduced<cons<typename X::value,Y> > { };
class K : public Reduced<K> { }; class S : public Reduced<S> { };
template<class X,class Y> class cons<cons<K,X>,Y> : public Reduced<X> { };
template<class X,class Y,class Z> class cons<cons<cons<S,X>,Y>,Z> : public Reduced<cons<cons<X,Z>,cons<Y,Z> > > { };
template<class X,class Y = typename X::value> class FixedPoint : public Reduced<typename FixedPoint<Y,typename Y::value>::value> { };
template<class X> class FixedPoint<X,X> : public Reduced<X> { };
using std::cout; using std::endl;
int main() { // // Run SSSK. Should output SK(SK) // cout << typeid(FixedPoint<cons<cons<cons<S,S>,S>,K> >::value).name() << endl << endl;
return 0; }
(link)
Loading up a cached webpage can not only save us from having to do ANY database queries, it can even allow us to serve up websites without touching our Ruby on Rails Server. Sounds kinda magical doesn’t it? Keep on reading for the good stuff.Small Lisp
The S-expression is the only data type of Small Lisp, so how do we represent truth values? Using the symbolic atoms T and F for true and false, respectively! (Common Lisp users, note that NIL does not represent false in Small Lisp.)
-m