• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: OO Theory misconceptions (was Re: can I make a list of
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OO Theory misconceptions (was Re: can I make a list of


  • Subject: Re: OO Theory misconceptions (was Re: can I make a list of
  • From: Michelle Steiner <email@hidden>
  • Date: Thu, 31 Jan 2002 08:53:19 -0700

On 1/31/02 1:24 AM, Emmanuel <email@hidden> wrote:

>I don't know if this is polymorphism or what, but what I regret much with
>AS is that you cannot make the usual operators work with different data
>types, like in the example "2 & 3" given earlier in this thread.

What would you want "2 & 3" to return? Currently, it returns {2, 3}.

>From our point of view (the scientifics', in short), it would be cool, say,
>if an osax could give a sense to x+y where x and y are lists.

What would you want that to return? My guess is that {1, 2} + {3, 4}
should return either {5, 9} or {5, 8, 6, 9}

I'm not sure what one would want, though, if the corresponding elements
of each list were of different data types.

Here's the code for the former:

set x to {1, 2}
set y to {4, 7}
set z to addlists(x, y)

to addlists(a, b)
set c to a
repeat with i from 1 to count of a
set item i of c to (item i of a) + (item i of b)
end repeat
return c
end addlists

Here's the code for the latter:

set x to {1, 2}
set y to {4, 7}
set z to addlists(x, y)

to addlists(a, b)
set c to {}
repeat with i in a
repeat with j in b
set c to c & i + j
end repeat
end repeat
return c
end addlists

It wouldn't be hard to code for different length lists.

----------------------------------------------------------------------
| Michelle Steiner | We're not human beings having a spiritual |
| | experience. We're spiritual beings |
| email@hidden | having a human experience. |
----------------------------------------------------------------------


  • Prev by Date: Re: Scripting OS X Mail app
  • Next by Date: Re: OO Theory misconceptions (was Re: can I make a list of
  • Previous by thread: Re: OO Theory misconceptions (was Re: can I make a list of
  • Next by thread: Re: OO Theory misconceptions (was Re: can I make a list of
  • Index(es):
    • Date
    • Thread