Suppose you have a list.
let x = ["a"; "b"; "c"];;
Convert it to a sequence:
#include <iostream> | |
using namespace std; | |
typedef struct list { | |
struct list * n; | |
int d; | |
} list; | |
void insert(list * l, int d) { |
module Main where | |
import qualified Control.Monad.State as M | |
import qualified Data.Array as A | |
import System.Random (StdGen, mkStdGen, randomR) | |
-- In a tic-tac-toe game, there is an 'X' player, and an 'O' player | |
data Player = PlayerO | PlayerX deriving (Eq, Show) |
module Main where | |
import qualified Data.Text as T | |
import qualified Text.Parsec.Pos as P | |
import qualified Data.SCargot as S | |
import qualified Data.SCargot.Common as C | |
import qualified Data.SCargot.Language.Basic as B | |
import qualified Data.SCargot.Repr.WellFormed as W | |
type Sexp = W.WellFormedExpr (C.Located T.Text) |
-- This version of fold applies 'f' to the head of the list '[a]' | |
-- to get a new accumulation 'acc', then it recurses into the tail | |
-- of the list '[a]' where it then repeats. This means that the | |
-- accumulated results are built up by adding in the elements | |
-- of the list, one at a time, starting with the first element | |
-- (on the left), and then moving through them, going right. | |
foldLeft :: (b -> a -> b) -> b -> [a] -> b | |
foldLeft f acc xs = | |
case xs of | |
[] -> acc |
/** | |
* A module for loading scripts asynchronously in most browsers. | |
* | |
* Note: this module uses the script.async attribute (see line 30), which | |
* tells the browser to load the script asynchronously. Most modern browsers | |
* support this async functionality, but those that don't will simply | |
* overlook it without causing problems. | |
* | |
* In addition, older versions of IE, Webkit, and Firefox 4+ that don't | |
* support the async attribute will still load scripts asynchronously |
Tutorial/cheat sheat for running/compiling OCaml.
Relational verification verifies relational properties that relate different programs.
To verify relational properties, one must (in principle) compare several runs of the same program.
Some examples of relational properties: