Skip to content

fnogatz/CHR.js-website

Repository files navigation

CHR.js Website

The static site that is chrjs.net. Just enter your Constraint Handling Rules, try adding some constraints, and download the generated solver code. Based on CHR.js.

Notation

Rules follow the CHR.js syntax. Additionally, the specification of a preamble containing native JavaScript is allowed:

{
  // preamble
  // code in this block can be used in the rules' guards and bodies

  function print (v) {
    console.log(v)
  }

  function pred (v) {
    return v < 5
  }
}

print_num     @ num(v) ==> ${ (v) => print(v) }
generate_nums @ num(v) ==> ${ (v) => pred(v) } | num(v+1)