# JX Workflow Language Quick Reference

[Makeflow](../makeflow/index.md) | [JX Workflow Tutorial](jx-tutorial.md) | [JX Workflow Reference](jx.md)

  Workflow    Rules 

 ```json
{
 # Required elements:
 "rules" : [
   # Array of rules goes here.
 ],
 # Optional elements:
 "define" : {
   "temp" : 32.5,
 },
 "environment" : {
   "PATH" : "/usr/local/bin:/bin",
 },
 "categories" : {
  "simulation" : {
      "resources" : { ... },
      "environment" : { ... },
      "allocation" : "auto" | "max" | "error"
  }
 }
}
```

 
```json
{
 # Required elements
 "command" : "./sim calib.dat > out",
 "inputs" : [ "sim", "calib.dat" ],
 "outputs" : [ "out" ],

 # Optional elements
 "local_job" : true | false,
 "resources" : {
     "cores":4,
     "memory":8,
     "disk":16,
     "wall-time":3600
 },
 "environment" : { ... }
 "category" : "simulation",
 "allocation" : "first"|"max"|"error"
}
```


  Values    Operators    Functions 

 ```json
"string"

42
3.14159

true | false

[ 1, 2, 3 ]

{ "temp" : 32.5,
  "name" : "fred" }
```

 
```json
a["b"]
func(x)

* % /
+ -

== != < <= > >=

not
and
or

expr for x in [1,2,3]
```


```json
    format( "str: %s int: %d float: %f",
            "hello", 42, 3.14159 )
    join( array, delim )
    range( start, stop, step )
    ceil( value )
    floor( value )
    basename( path )
    dirname( path )
    escape( string )
    len( array )
    fetch( URL/path )
    select( array, boolean )
    project( array, expression )
    schema( object )
    like( object, string )
```


  Examples 

```json
# A hash at the beginning of a line starts a comment.

# Generate an array of 100 files named "output.1.txt", etc...
[ "output."+x+".txt" for x in range(1,100) ]

# Generate one string containing those 100 file names separated by a space.
join( [ "output."+x+".txt" for x in range(1,100) ], " ")

# Generate five jobs that produce output files alpha.txt, beta.txt, ...
{
  "command" : "simulate.py > "name + ".txt",
  "outputs" : [ name + ".txt" ],
  "inputs"  : "simulate.py",
} for name in [ "alpha", "beta", "gamma", "delta", "epsilon" ]
```


