-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.rkt
executable file
·31 lines (27 loc) · 945 Bytes
/
cli.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/racket
#lang racket/base
(require "functions.rkt")
(require racket/cmdline)
(define n (make-parameter 10))
(define optimize-level (make-parameter 2))
(command-line
#:once-each
[("-n" "--number") number "Gitter-Seitenlänge"
(n (string->number number))]
#:once-any
[("--optimize-0") "ohne Optimierung"
(optimize-level 0)]
[("--optimize-1") "leichte Optimierung"
(optimize-level 1)]
[("--optimize-2") "volle Optimierung"
(optimize-level 2)])
(printf "n=~a~n" (n))
(cond [(= (optimize-level) 2)
(display "Volloptimiert:\n")
(time (exact->inexact (pi-approx-opt2 (n))))]
[(= (optimize-level) 1)
(display "Etwas optimiert:\n")
(time (exact->inexact (pi-approx-opt1 (n))))]
[(= (optimize-level) 0)
(display "Nicht optimiert:\n")
(time (exact->inexact (pi-approx (n))))])