This file contains hidden or 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
/** | |
* The function defining our user interface. | |
*/ | |
start = -> <>Hello, web!</> //HTML-like content. As the last value of the function, this is the result. | |
//Reduced syntax for trivial functions | |
/** | |
* Create and start a server delivering user interface [start] | |
*/ | |
start_server(one_page_server("Hello", start)) |
This file contains hidden or 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
/** | |
* The function defining our user interface. | |
*/ | |
def start(): | |
<>Hello, web!</> //HTML-like content. As the last value of the function, this is the result. | |
/** | |
* Create and start a server delivering user interface [start] | |
*/ | |
server: |
This file contains hidden or 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
server: | |
one_page_server("Hello", def(): <>Hello, web!</>) |
This file contains hidden or 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
/** | |
* Add a path called [/storage] to the schema of our graph database. | |
* | |
* This path is is a dictionary indexed by [string]s of values | |
* of type [option(string)], i.e. values that may either be | |
* a string or omitted. To find out whether the value is present, | |
* one should use pattern-matching - case [{some: ...}] if the | |
* value is present, [{none}] if the value is omitted. | |
* | |
* Note: db is a keyword. |
This file contains hidden or 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
/** | |
* Add a path called [/storage] to the schema of our graph database. | |
* | |
* This path is is a dictionary indexed by [string]s of values | |
* of type [option(string)], i.e. values that may either be | |
* a string or omitted. To find out whether the value is present, | |
* one should use pattern-matching - case [{some: ...}] if the | |
* value is present, [{none}] if the value is omitted. | |
* | |
* Note: db is a keyword. |
This file contains hidden or 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
world_weather_parser = | |
request = xml_parser | |
<request> <type>_*</> <query>query={Xml.Rule.string}</> </> -> query | |
current = xml_parser | |
<current_condition>_*</current_condition> -> void | |
entry = xml_parser | |
<weather> <date>dateStr={Xml.Rule.string}</> | |
<tempMaxC>tempMax={Xml.Rule.integer}</> | |
<tempMaxF>_*</> | |
<tempMinC>tempMin={Xml.Rule.integer}</> |
This file contains hidden or 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
/** | |
* @param source A function whose calls will be monitored | |
* @param observer A function triggered whenever [source] is called | |
*/ | |
(function(source, observer){ | |
var original_apply = source.apply; | |
source.apply = function(args) { | |
observer(); | |
original_apply.apply(args); | |
} |
This file contains hidden or 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
(** | |
Fold upon a matrix in a spiral. | |
Note: implementation is tail-rec | |
@param f A function to apply consecutively to [init] and to elements of the matrix | |
@param init An initial value (see the general definition of fold functions for more details) | |
@param matrix A matrix, i.e. an array of arrays of the same length | |
*) | |
let fold_spiral f init matrix = |
This file contains hidden or 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
(** | |
Enumerate the values of a matrix in spiral order. | |
@param matrix A matrix, i.e. an array of arrays of the same length | |
@return A lazy enumeration of the matrix. | |
*) | |
let enum_spiral matrix = | |
let rec loop ~depth = | |
let minx = depth | |
and maxx = width - depth - 1 |
This file contains hidden or 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 "common.hpp" | |
template<class T> | |
void cio(const char* text, T& result) | |
{ | |
std::cout << text; | |
std::cin >> result; | |
} |