[racket] About genericity...

From: Alejandro Zamora Fonseca (terefv at ltu.sld.cu)
Date: Mon Apr 7 09:02:39 EDT 2014

Yes, it's the second guess, it is my only knowlege about genericity in 
Lisp.
I wanted to know how to do in Racket ... :)
thanks for all answers,
Alejandro

2014-04-06 00:21, Daniel Prager escribió:
> Hi Roman
> 
>> I think, Alejandro wanted to add clauses in different places (generic 
>> in one module, added method in another, for example).
> 
> Quite possibly, or perhaps not! ;-)
> 
> Alejandro gave an example of one declaration mechanism that he'd seen
> in CL. Hard to tell whether that's optimal for his context, or if
> that's what he's familiar with.
> 
> Dan
> 
> On Thu, Apr 3, 2014 at 8:43 PM, Roman Klochkov <kalimehtar at mail.ru> 
> wrote:
> 
>> Or even simpler 
>> 
>> (define (dup a)
>>   (cond
>>     [(string? a) (string-append a a)]
>>     [(integer? a) (list a a)])
>> 
>> :-)
>> 
>> I think, Alejandro wanted to add clauses in different places (generic 
>> in one module, added method in another, for example).
>> 
>> Thu,
I
3 Apr 2014 20:11:36 +1100 от Daniel Prager <daniel.a.prager at gmail.com>:
>> 
>>> Here's an out-of-the-box option, using Racket's pattern matching 
>>> [1] with the (? predicate) form:
>>> 
>>> (define/match (dup a)
>>>   [((? string?)) (string-append a a)]
>>>   [((? integer?)) (list a a)])
>>> 
>>> Dan
>>> 
>>> ____________________
>>>   Racket Users list:
>>>   http://lists.racket-lang.org/users [2]
>> 
>> --
>> Roman Klochkov
> 
> --
> 
> DANIEL PRAGER
> Agile/Lean Coaching, Software Development and Leadership
> 
> Startup: www.youpatch.com [3]
>  Twitter: @agilejitsu [4] 
> Blog: agile-jitsu.blogspot.com [5]
> 
> Links:
> ------
> [1]
> http://docs.racket-lang.org/reference/match.html#%28form._%28%28lib._racket%2Fmatch..rkt%29._define%2Fmatch%29%29
> [2] http://lists.racket-lang.org/users
> [3] http://www.youpatch.com
> [4] https://twitter.com/agilejitsu
> [5] http://agile-jitsu.blogspot.com/

--

Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/


Posted on the users mailing list.