Hi,

I spent all weekend buring imperative brain cells, and finally came up with some code that worked, but encountered something I don't understand. The code ...

fun {DoScan Is}
% Return a list that is the list of sub-strings of it's input
% defined by the delimiter character (space)
   X
in
   % Descend into the source string and work on the way out
   case Is
   of nil then
      nil | nil
   [] I|Ir then
      X = {DoScan Ir}
      case I
      of & then
         nil | X
      else
         (I|X.1) | X.2
      end
   end
end

works beautifully, and I must say it surprised me how elegantly it came out after all the struggle (and particularly klunky code) I went through to get my head around it.

Anyway, the first version had the the list construction things as
[ nil nil ]
[ nil X ]
[ I|X.1 X.2 ]

but as it was coming back out of the recursion, the second element of the list from [I|X.1 X.2] was getting increasingly nested. eg after a couple of returns up the stack, the function was returning

[[105 110] [[nil]]]

instead of what I expected which would be

[[105 110] nil ]

Can someone explain that? What is the difference between
[ nil nil ]
and
nil | nil

Cheers,
Jonathan.

PS ... I'm really starting to love Oz/Mozart, despite that it makes my head hurt. :)

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to