Version 5

    <= // assign

    <| // iterate

     

    within {..} < and > are normal infix comparators.

     

    Person p <| persons
    {p.age > 20}
    boolean b <= {p.age > 20}
    Pet pet <= /p/pets{name == rover}/
    Pet pet <| {persons.pets}
    String name <= p.name
    {pet.name == "rover"}
    
    
    

     

    use the "LHS" in the RHS:

     

    rule x when /* empty */ then {
      List list <= { new ArrayList() }
      sub(
          int i <| { [1, 2, 3, 4, 5, 6] }
          Invader invader <= { invader = new Invader();
                               invader.width = conf.invader1Width;
                               invader.height = conf.invader1Height;
                               invader.speed = conf.invader1Speed;
                               invader.x = 90 * i;
                               invader.y = 40 + conf.invader1Height;
                               invader; )
          { list.add( invader ); }
          { insert( invader ) ); }
      )
      { insert( list ) }
    }