Skip to content

Commit

Permalink
added join function
Browse files Browse the repository at this point in the history
lisätty join-funktio
  • Loading branch information
fergusq committed Jun 19, 2018
1 parent 0920e34 commit 1096ff8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/org/kaivos/röda/commands/HeadAndTailPopulator.java
Expand Up @@ -97,5 +97,17 @@ public static void populateHeadAndTail(RödaScope S) {
in.forAll(out::push);
args.forEach(out::push);
}, Arrays.asList(new Parameter("values", false)), true));

S.setLocal("join", RödaNativeFunction.of("join", (typeargs, args, kwargs, scope, in, out) -> {
RödaValue sep = args.get(0);
int i = 0;
while (true) {
RödaValue value = in.pull();
if (value == null) break;
if (i != 0) out.push(sep);
out.push(value);
i++;
}
}, Arrays.asList(new Parameter("value", false)), false));
}
}

0 comments on commit 1096ff8

Please sign in to comment.