On Saturday, September 20, 2003, at 05:32 PM, Andy Burns wrote:


I re-plead "dumb-for-a-day"

Make this function first:


function catProduct sl1 sl2
   ...
end catProduct

This function takes two lists and creates the concatenation product. That is, it creates another list that is all the ways a string can be taken from the first list and concatenated with a string from the second list. If there are n1 strings in the first list and n2 strings in the second, the function will return a list of n1 * n2 strings.

Here is an of-the-top-of-my-head stab at that:

function catProduct sl1 sl2
   local cp  -- empty
   repeat for each string s1 in sl1
      repeat for each string s2 in sl2
         put s1 & s2 & LF after cp
      end repeat
   end repeat
   return cp  -- keep final LF
end catProduct

The "identity" of this function is a list consisting of a single line with the "identity" of '&', that is, empty. In Revolution, that is simply LF.

Now suppose you built your array phoneCalls to return lines instead of words. You could do this:

...
put LF into wordList  -- identity
repeat for each char digit in phoneNumber
  put catProduct(wordList, phoneCalls[digit]) into wordList
end repeat
-- optionally remove LF from end of wordList
...

Again off the top of my head.

This probably has some problems near the ends and near the corners; you should tinker with very small trivial phone numbers.

This should get you started.

Whoops. I forgot to make this a recursion example. Oh, well. Maybe next time.

Dar Scott


_______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to