1. Re: split() function

Jiri, you are impossible to please!  smile
I was going to leave printing empty braces instead of double double quotes as an
exercise for the reader, but since you insist...

procedure smart_print_recursive(object o)
 if atom(o) then
  printf(1, "%g", {o})
 elsif length(o) = 0 then
  puts(1, "{}")
 elsif equal(repeat(1, length(o)), o >= ' ' and o <= 255) then
  printf(1, "\"%s\"", {o})
 else
  puts(1, "{ ")
  smart_print_recursive(o[1])
  for i = 2 to length(o) do
   puts(1, ", ")
   smart_print_recursive(o[i])
  end for
  puts(1, " }")
 end if
end procedure

procedure smart_print(object o)
 smart_print_recursive(o)
 puts(1, "\n")
end procedure

-- Pete

On Thu, 4 May 2000 13:22:07 +1200, Jiri Babor <J.Babor at GNS.CRI.NZ> wrote:
>I have been using the same split() function as Pete's, except the
>length of the string needs to be calculated only once.
>
>Btw, Ian's original function, while slower, correctly handles the
>boundary cases.
>
>Pete's smart_print is a nice, compact alternative to Gabriel's
>print.e. I am not quite sure, but I would probably prefer an empty pair
>of braces, not a pair of quotation marks to signify an empty sequence
>generally. ;)  jiri

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu