unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Re: design advice on predicate name
@ 2006-08-20  6:29 Marco Maggi
  0 siblings, 0 replies; 5+ messages in thread
From: Marco Maggi @ 2006-08-20  6:29 UTC (permalink / raw)


"Neil Jerram" wrote:
>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).

Yes. The abstract behind having a NAN? for my custom
vectors and matrices is to let the user write math
functions that work for both numbers and composite
numeric objects. To let him try them out. I am not sure
about how significant it is, though.

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

Predicates that act upon numbers can be applied to
numbers, vectors and matrices. And they always work
like MAP-NAN? Using the number/vector/matrix oriented
functions of Octave it is possible to write custom
predicates that behave in the same way.

Octave also has 'all()' and 'any()' which return a single
0/1 result if all or any of the elements of a num/vec/mat
is 0 or 1. So Octave requires two functions call to
achieve the result of HIT-NAN?

--
Marco Maggi

"They say jump!, you say how high?"
Rage Against the Machine - "Bullet in the Head"



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


^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: design advice on predicate name
@ 2006-08-18 19:01 Marco Maggi
  2006-08-19 10:37 ` Neil Jerram
  0 siblings, 1 reply; 5+ messages in thread
From: Marco Maggi @ 2006-08-18 19:01 UTC (permalink / raw)


"Neil Jerram" wrote:
>"Marco Maggi" <marco.maggi-ipsu@poste.it> 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.



--
Marco Maggi

"They say jump!, you say how high?"
Rage Against the Machine - "Bullet in the Head"



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


^ permalink raw reply	[flat|nested] 5+ messages in thread
* design advice on predicate name
@ 2006-08-18  5:42 Marco Maggi
  2006-08-18 13:49 ` Neil Jerram
  0 siblings, 1 reply; 5+ messages in thread
From: Marco Maggi @ 2006-08-18  5:42 UTC (permalink / raw)


Ciao,

  I have two predicate functions that act upon a vector
or matrix: the hit predicate produces a single #t/#f
result while the map predicate produces a vector or rank
2 array of #t/#f values.

  Using generic functions I can write functions with
math operators that act upon common numbers or vector and
matrices without visible difference.

  Example: I have two predicates HIT-NAN? and MAP-NAN?
which one it is better to call NAN?

  By the way: the NUMBER? predicate is supposed to return
#t for proper number SMOBs or for any object that can
be used as argument of math operators?


--
Marco Maggi

"They say jump!, you say how high?"
Rage Against the Machine - "Bullet in the Head"



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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-08-20  6:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-20  6:29 design advice on predicate name Marco Maggi
  -- strict thread matches above, loose matches on Subject: below --
2006-08-18 19:01 Marco Maggi
2006-08-19 10:37 ` Neil Jerram
2006-08-18  5:42 Marco Maggi
2006-08-18 13:49 ` Neil Jerram

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).