Hi Laurent,

I certainly appreciate the other potential references.  I will certainly
explore them.
You got me thinking now about what would be considered the most optimal.
I'll explore that on my own and if I feel the need report any huge
descrepancies.

Thanks for the response!
~Paul

On Thu, Nov 8, 2018 at 6:06 PM Laurent Rosenfeld <
laurent.rosenf...@googlemail.com> wrote:

> To me, using *map *in such a context is not the best (although it can
> obviously be done).
>
> IMHO, *map *is really intended to generate a list from another list. In
> your case, a *for *loop would make more sense to me. Even the use of *grep
> *(or *first*) would be more natural than *map*.
>
> But that's probably a matter of personal taste.
>
> Best,
> Laurent.
>
>
>
>
>
> Le jeu. 8 nov. 2018 à 23:46, Paul Procacci <pproca...@gmail.com> a écrit :
>
>> Had time to think about this on the drive home.
>> I've eliminated the for loop which was my goal.
>> Any "better" or "cleaner" way of doing this, I'm all ears.  ;)
>>
>> die Some::Exception.new.throw
>>     if %!panels.elems && !%!panels.values.map({
>>       $end_y < .start_y || $start_x > .end_x ||
>>       $start_y > .end_y || $end_x < .start_x
>>     }).so;
>>
>>
>> On Thu, Nov 8, 2018 at 4:27 PM Paul Procacci <pproca...@bizjournals.com>
>> wrote:
>>
>>> I don't like this:
>>>
>>>
>>> for %!panels<>:k {
>>>      die Some::Exception.new.throw
>>>        unless $start_y > %!panels{$_}.end_y   || $end_y   <
>>> %!panels{$_}.start_y ||
>>>               $end_x   < %!panels{$_}.start_x || $start_x >
>>> %!panels{$_}.end_x;
>>>
>>> }
>>>
>>>
>>> In short, I have a objects stored in hash %!panels that contain the
>>> (x,y) coordinates of a square.
>>>
>>> The function above works; throwing an exception if any of the squares
>>> overlap, but I don't like using the for loop here.
>>>
>>> I'm hoping someone here can provide a similar golfed example.
>>>
>>> I've been looking at `map` and `so`, but I just can't get my brain to
>>> work.
>>>
>>>
>>> Thanks in Advance,
>>>
>>> ~Paul
>>>
>>>
>>
>> --
>> __________________
>>
>> :(){ :|:& };:
>>
>

-- 
__________________

:(){ :|:& };:

Reply via email to