"Marco Maggi" <[EMAIL PROTECTED]> writes:

> "Neil Jerram" wrote:
>>"Marco Maggi" <[EMAIL PROTECTED]> writes:
>>>   Example: I have two predicates HIT-NAN? and MAP-NAN?
>>> which one it is better to call NAN?
>>
>>I'm afraid I don't understand.  Perhaps you could write
>>the down for the two possibilities that you have in mind.
>
> For a vector of real numbers like this [1 +nan.0 3]:
>
> * hit-nan? returns #t because at least one element
>   is nan;
>
> * map-nan? returns #(#f #t #f), one boolean for each
>   element;
>
> the same for matrices. map-nan? works like the 'isnan'
> function of GNU Octave, which for the example vector
> would return [0 1 0].
>
>   hit-nan? can be used in the conditional of IF and
> COND, while map-nan? must be inspected. For this reason
> I guess that hit-nan? should be the nan?, but, to the
> best of my knowledge, GNU Octave defines only the map-nan?
> equivalent so I do not know how useful can be hit-nan?
> in practice.

Thanks for explaining.  My intuition is that the NAN? name should be
used only for a procedure which takes a single number and reports
whether it is NAN or not (as #t/#f).

For your `hit-nan?' procedure I would use the name `contains-nan?' or
`any-nan?'.  But on the other hand, if `hit-nan?' is the name that
first occurred to you, why not stick with it?  For your `map-nan?'
procedure I would use `map-nan?', as you have done.

Is it a feature of Octave that any predicate can automatically map
over a vector, or can `isnan' only be applied to a vector?

Regards,
        Neil



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user

Reply via email to