[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Comparison operators for strings /and/ numbers?
From: |
Arne Babenhauserheide |
Subject: |
Re: Comparison operators for strings /and/ numbers? |
Date: |
Thu, 24 Aug 2017 10:29:41 +0200 |
Hi Christopher,
You can use GOOPS to make them generic:
> (import (oop goops))
> (< "a" "b")
<unnamed port>:3:0: <unnamed port>:3:0: In procedure <: Wrong type argument in
position 1: "a"
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
[1]> (define-method (< (a <string>) (b <string>)) (string<? a b))
[1]> (< "a" "b")
$1 = #t
For some functions you might need to call (define-generic <function>)
before this (you’ll notice because define-method will signal an error).
Best wishes,
Arne
Christopher Howard <address@hidden> writes:
> 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.
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken
signature.asc
Description: PGP signature