Guest User

Untitled

a guest
Feb 18th, 2013
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Oz 1.29 KB | None | 0 0
  1. (* Try 1, based on Hongwei's string_length
  2. * It did look simpler at one point, but attempting to debug
  3. * resulted in the following, which didn't help. Time to start over! *)
  4.  
  5. fun string_caps
  6.   {n:nat| n > 0}
  7.   (str: string(n)): string n =  
  8.   let
  9.     //val sstr = string_of_string1(str)
  10.     val [n:int] str = string1_of_string (str)
  11.     val n = string_length (str)
  12.     val initi:sizeLt(n) = size1_of_int1(0)
  13.     fun loop (str: string n, i: sizeLt(n)): string n =
  14.       let
  15.         val [n:int] str = string1_of_string (str)
  16.       in
  17.         if i < n then
  18.           let
  19.             val x = toCaps(str[i])
  20.             val x = tostring(x)
  21.             val x = string1_of_string(x)
  22.             val x = string_of_string1(x)
  23.             val ii = i+1
  24.             val xs = loop (str, ii)
  25.             val xs = string1_of_string(xs)
  26.             val xs = string_of_string1(xs)
  27.             val xxs = x + xs
  28.             val xxs = string1_of_string(xxs)
  29.             val _ = print(xxs)
  30.             val _ = $showtype(x)
  31.             val _ = $showtype(xs)
  32.             val _ = $showtype(xxs)
  33.           in
  34.             xxs
  35.           end
  36.         else string1_of_string("")
  37.         //else string_of_string1(" ") //CHANGE THIS TO ""
  38.       end
  39.   in
  40.     loop (str, initi)
  41.   end // end of [string_caps]
Advertisement
Add Comment
Please, Sign In to add comment