RosettaCodeData/Task/Repeat-a-string/ECL/repeat-a-string-2.ecl

10 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);