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

Re: [Scheme-reports] Pattern matching and list comprehensions






Sat, 22 Mar 2014 07:48:49 +0800 от Alan Manuel Gloria <almkglor@x>:
In Scheme, any implementation of Scheme will get traction once it has
a minimum of RnRS-compatibility (and RnRS is a very short standard,
except for n=6) plus a module system plus a library repository, and
each Scheme implementation becomes its own little island, Any short,
succinct operator that arises on one island will not be understood on
another island. Hence the need in Scheme for fully specifying what
you mean in each name.
This is where the notion of portability arises, as the use of only those identifiers that are defined in the Report.
> ((append) is not needed here.)

Actually, it is:
Surely it is, I was thinking of some other thing at that moment, sorry.

(let ((x (list 1 2 3))
      (y (list 4 5 6)))
  (apply f (append x y)))
==
(f 1 2 3 4 5 6)

but:

(let ((x (list 1 2 3))
      (y (list 4 5 6)))
  (apply f x y))
==
(f (list 1 2 3) 4 5 6)



>
> It's not only that -- it is also relevant how arguments are applied to
> the predicate. To be honest, I have no intuition of whether such
> generalization is good. Can you come up with any real-world usage
> example? (Like: multiple argument map allows you to easily define the
> code that computes the dot product)
>
> Sorry, I don't have production examples right before my eyes now, so
> anything I come up with would be somewhat artificial.
> Let's say you have two function graphs in two buffers and want to compute
> their relation at all points where the denominator is not zero:
>
> (define nom-list)
> (define denom-list)
> (define ratio-list (call-with-values (lambda () (filter (lambda (a b) (not
> (zero? b))) nom-list denom-list)) (lambda (l1 l2) (map / l1 l2))))
>
> (I intentionally have not used any more procedures of prelude.scm in this
> example.)
>
>
> Pozdrawiam
> M.
>
>
>
> С уважением,
>
> denin@x
>
> _______________________________________________
> Scheme-reports mailing list
> Scheme-reports@x
> http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports
>


С уважением,

denin@x
_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports