Re: Arbitrary mathematical relations, not just hashes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Apr 6, 2008 at 7:52 PM, Kelly Jones <kelly.terry.jones@xxxxxxxxx>
wrote:

> Many programming languages (including Perl, Ruby, and PHP) support hashes:
>
> $color['apple'] = 'red';
> $color['ruby'] = 'red';
>
> $type['apple'] = 'fruit';
> $type['ruby'] = 'gem';
>
> This quickly lets me find the color or type of a given item.
>
> In this sense, color() and type() are like mathematical functions.
>
> However, I can't easily find all items whose $color is 'red', nor all
> items whose $type is 'fruit'. In other words, color() and type()
> aren't full mathematical relations.
>
> Of course, I could create the inverse function as I go along:
>
> $inverse_color['red'] = ['apple', 'ruby']; # uglyish, assigning list to
> value
>
> and there are many other ways to do this, but they all seem kludgey.
>
> Is there a clean way to add 'relation' support to Perl, Ruby, or PHP?
>
> Is there a language that handles mathematical relations
> naturally/natively?
>
> I realize SQL does all this and more, but that seems like overkill for
> something this simple?
>
> --
> We're just a Bunch Of Regular Guys, a collective group that's trying
> to understand and assimilate technology. We feel that resistance to
> new ideas and technology is unwise and ultimately futile.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux