RosettaCodeData/Task/Repeat-a-string/ECL/repeat-a-string-2.ecl
2016-12-05 23:44:36 +01:00

9 lines
275 B
Prolog

RepeatString(STRING InStr, INTEGER Cnt) := FUNCTION
rec := {STRING Str};
ds := DATASET(Cnt,TRANSFORM(rec,SELF.Str := InStr));
res := ITERATE(ds,TRANSFORM(rec,SELF.Str := LEFT.Str + RIGHT.Str));
RETURN Res[Cnt].Str;
END;
RepeatString('ha',3);
RepeatString('Who',2);