Paste # 14462
2023-11-18 18:19:24

Fork as a new paste.

Paste viewed 514 times.


#lang racket
(define (outliers lon)
   [;; mean: (listof Num) -> Num
    (define (mean lon)
       [(empty? lon) 0]
       [else (/ (+ (first lon) (mean (rest lon))) (length lon))]))
    ;; variance: (listof Num) -> Num
    (define (variance lon)
       [(empty? lon) 0]
       [else (/ (+ (sqr (- (first lon) mean)) (variance (rest lon))) mean)]))]

    ;; term: (listof Num) -> Num
    (define (term lon) (sqr (- (first lon) mean)))]

    [(empty? lon) empty]
    [(> term variance) (cons (first lon) (rest term))]
    [else (rest outliers)])))


#<syntax:/home/pasterack/pasterack/tmp/14462/14462code.scrbl:5:0 "#lang racket">:17:50: read-syntax: expected `)` to close `(` on line 3, found instead `]`
  possible cause: indentation suggests a missing `)` before line 4
   /home/pasterack/racket88/collects/syntax/module-reader.rkt:214:17: body
   /home/pasterack/racket88/collects/syntax/module-reader.rkt:211:2: wrap-internal
   /home/pasterack/racket88/collects/racket/../syntax/module-reader.rkt:76:9: wrap-internal/wrapper
   /home/pasterack/racket88/share/pkgs/scribble-lib/scribble/private/manual-code.rkt:138:19: loop
   /home/pasterack/racket88/share/pkgs/scribble-lib/scribble/private/manual-code.rkt:112:0: get-tokens
   /home/pasterack/racket88/share/pkgs/scribble-lib/scribble/private/manual-code.rkt:56:0: typeset-code
   body of "/home/pasterack/pasterack/tmp/14462/14462code.scrbl"
   .../private/map.rkt:40:19: loop
   body of "/home/pasterack/racket88/share/pkgs/scribble-lib/scribble/run.rkt"