Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <v4do46$22q3g$1@dont-email.me>
Deutsch   English   Français   Italiano  
<v4do46$22q3g$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.nobody.at!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: "B. Pym" <No_spamming@noWhere_7073.org>
Newsgroups: comp.lang.lisp
Subject: Re: Loopy
Date: Thu, 13 Jun 2024 03:13:11 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <v4do46$22q3g$1@dont-email.me>
References: <v4552t$3poln$1@dont-email.me> <v465p2$7ib2$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Thu, 13 Jun 2024 05:13:11 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="1732be28450302a0a7b2cfd1fb42f3c5";
	logging-data="2189424"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/iAPQV/WtNTtO/mjHJTPc1"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:ks+KJcvKNs+BBd4XcGUzfTMyAaQ=
Bytes: 2030

On 6/10/2024, B. Pym wrote:

> Peter Seibel wrote:
> 
>  >   (loop for x across array-of-numbers
>  >         minimizing x into min
>  >         maximizing x into max
>  >         summing x into total
>  >         counting t into count
>  >         finally (return (list min max (/ total count))))
> 
> 
> In Gauche Scheme, it's a one-liner.
> 
> (use gauche.sequence)
> 
> (define v #(0 2 -3 99 48 35 86 27 50 18))
> (define count (vector-length v))
> 
> 
> `(,(find-min v) ,(find-max v) ,(/ (fold + 0 v) count))
>   ===>
> (-3 99 181/5)

Another way.

(define v #(0 2 -3 99 48 35 86 27 50 18))
(define count (vector-length v))

(let ((r (mul-vec-reduce (list + max min) v)))
  (reverse (cons (/ (pop! r) count) r)))

  ===>
(-3 99 181/5)

Given:

(use srfi-43) ;; vector-fold

(define (mul-vec-reduce konses vec)
  (let ((len (length konses)))
    (vector-fold
      (lambda (i accum x)
        (if (null? accum)
          (make-list len x)
          (map
            (lambda (f a b) (f a b))
            konses
            (make-list len x)
            accum)))
      '()
      vec)))