% ---------------------------------------------------------------------------- % % stringconcat.m % Ralph Becket <rbeck@microsoft.com> % Tue Jan 9 15:56:12 GMT 2001 % vim: ts=4 sw=4 et tw=0 wm=0 ff=unix % % NOTE: The C version simply appends to the end of a preallocated % buffer, doubling the buffer size when necessary. Not what I would strictly % call string concatenation. % % ---------------------------------------------------------------------------- % :- module mytest. :- interface. :- import_module io. :- pred main(io__state, io__state). :- mode main(di, uo) is det. :- implementation. :- import_module string, int, list, require. main --> io__command_line_arguments(ArgV), ( { ArgV = [], N = 1 } ; { ArgV = [Arg], N = string__det_to_int(Arg) } ; { ArgV = [_,_|_], error("usage: nestedloops [N]") } ), io__write_int(string__length(hellos(N, ""))), io__nl. :- func hellos(int, string) = string. hellos(I, S) = ( if I > 0 then hellos(I - 1, S ++ "hello\n") else S ).