guile-user
[Top][All Lists]
Advanced

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

Re: Comparison operators for strings /and/ numbers?


From: Chris Vine
Subject: Re: Comparison operators for strings /and/ numbers?
Date: Thu, 24 Aug 2017 14:41:59 +0100

On Thu, 24 Aug 2017 14:31:41 +0100
Chris Vine <address@hidden> wrote:
> On Wed, 23 Aug 2017 22:05:37 -0800
> Christopher Howard <address@hidden> wrote:
> > Hi, in another lisp I have been working with, it has <, >, and ==
> > (structure equality) operators which can take string arguments,
> > number arguments, or a mixture of both. But it seems in guile that
> > there are separate comparison operators for strings and for
> > numbers. This makes sense but is not very convenient for my present
> > purpose. Is there some other guile operators or extension operators
> > that will handle both? I could make some I'm sure, but I don't want
> > to reinvent the wheel.  
> 
> The predicate equal? will compare numbers, strings and records.
> 
> https://www.gnu.org/software/guile/docs/master/guile.html/Equality.html#index-equal_003f

I meant to add, but failed to do so, that as far as I am aware there is
no built-in polymorphic < or > procedure that will take strings as well
as numbers.  As a simple work-around you could use type predicates in a
cond expression to dispatch the appropriate comparison procedure for
the type in question.

Chris



reply via email to

[Prev in Thread] Current Thread [Next in Thread]