createInstruction method

  1. @override
List<Instruction> createInstruction(
  1. TurtleState turtle,
  2. Map argv
)
override

Creates instructions.

Implementation

@override
List<Instruction> createInstruction(TurtleState turtle, Map argv) {
  if (commands.isEmpty) return [];

  var instructions = <Instruction>[];
  for (var i = 0; i < times(Map.from(argv)); i++) {
    var copy = Map.from(argv);
    copy[repcount] = i + 1;
    var list = List<Instruction>.of(commands
        .map((command) => command.createInstruction(turtle, copy))
        .expand((x) => x));
    instructions.addAll(list);
  }
  return instructions;
}