From eb2481cd49d28d324a12d7cd062c8d402f47e9bd Mon Sep 17 00:00:00 2001 From: markusde Date: Sat, 29 Oct 2022 15:21:25 -0700 Subject: update people --- .../good-code-bad-code/good-code-bad-code.rkt | 50 ++++++++++++++++++++++ entries/markusde/good-code/good-code.rkt | 50 ---------------------- people.json | 4 ++ 3 files changed, 54 insertions(+), 50 deletions(-) create mode 100644 entries/markusde/good-code-bad-code/good-code-bad-code.rkt delete mode 100644 entries/markusde/good-code/good-code.rkt diff --git a/entries/markusde/good-code-bad-code/good-code-bad-code.rkt b/entries/markusde/good-code-bad-code/good-code-bad-code.rkt new file mode 100644 index 0000000..0f45fc5 --- /dev/null +++ b/entries/markusde/good-code-bad-code/good-code-bad-code.rkt @@ -0,0 +1,50 @@ +#lang racket +;; Requires Algebraic Racket https://docs.racket-lang.org/algebraic/index.html + +;; When I learned how to program, we kind of had to learn by osmosis. +;; They would show us good code, and bad code, and say +;; "write a fibonacci function which relies on how bad your code is" + + +;; Generates a syntax object which comutes the nth fibonacci +;; number with fib(n) linter warnings +(define (generate-fib n) + (cond + [(zero? n) (syntax 0)] + [(equal? n 1) (datum->syntax #'lex (quote ((lambda (x) 1) "gregor")))] + [else (datum->syntax #'lex + (quasiquote (+ (unquote (generate-fib (- n 1))) + (unquote (generate-fib (- n 2))))))])) + +(eval (generate-fib 0)) +(eval (generate-fib 1)) +(eval (generate-fib 2)) +(eval (generate-fib 3)) +(eval (generate-fib 4)) + + +;; Compiles a racket program that computes the fibonacci numbers +;; Reports the number of linter warnings +;; Leaves the compiled fibonacci-n binary, which computes fib(n) +(define (fibonacci n) + (begin + (define outfile (string-append "fibonacci-" (number->string n) ".rkt")) + (define out (open-output-file outfile #:exists 'replace)) + (displayln "#lang algebraic/racket/base/linted" out) + (writeln (syntax->datum (generate-fib n)) out) + (close-output-port out) + (define err-out (let ([str-port (open-output-string)]) + (parameterize ([current-error-port str-port]) + (system (string-append "raco exe " outfile)) + ) + (get-output-string str-port))) + (delete-file outfile) + (println (/ (length (string-split err-out "\n")) 4)))) + +(fibonacci 0) +(fibonacci 1) +(fibonacci 2) +(fibonacci 3) +(fibonacci 4) + + diff --git a/entries/markusde/good-code/good-code.rkt b/entries/markusde/good-code/good-code.rkt deleted file mode 100644 index 0f45fc5..0000000 --- a/entries/markusde/good-code/good-code.rkt +++ /dev/null @@ -1,50 +0,0 @@ -#lang racket -;; Requires Algebraic Racket https://docs.racket-lang.org/algebraic/index.html - -;; When I learned how to program, we kind of had to learn by osmosis. -;; They would show us good code, and bad code, and say -;; "write a fibonacci function which relies on how bad your code is" - - -;; Generates a syntax object which comutes the nth fibonacci -;; number with fib(n) linter warnings -(define (generate-fib n) - (cond - [(zero? n) (syntax 0)] - [(equal? n 1) (datum->syntax #'lex (quote ((lambda (x) 1) "gregor")))] - [else (datum->syntax #'lex - (quasiquote (+ (unquote (generate-fib (- n 1))) - (unquote (generate-fib (- n 2))))))])) - -(eval (generate-fib 0)) -(eval (generate-fib 1)) -(eval (generate-fib 2)) -(eval (generate-fib 3)) -(eval (generate-fib 4)) - - -;; Compiles a racket program that computes the fibonacci numbers -;; Reports the number of linter warnings -;; Leaves the compiled fibonacci-n binary, which computes fib(n) -(define (fibonacci n) - (begin - (define outfile (string-append "fibonacci-" (number->string n) ".rkt")) - (define out (open-output-file outfile #:exists 'replace)) - (displayln "#lang algebraic/racket/base/linted" out) - (writeln (syntax->datum (generate-fib n)) out) - (close-output-port out) - (define err-out (let ([str-port (open-output-string)]) - (parameterize ([current-error-port str-port]) - (system (string-append "raco exe " outfile)) - ) - (get-output-string str-port))) - (delete-file outfile) - (println (/ (length (string-split err-out "\n")) 4)))) - -(fibonacci 0) -(fibonacci 1) -(fibonacci 2) -(fibonacci 3) -(fibonacci 4) - - diff --git a/people.json b/people.json index 347aaa1..83b6ca3 100644 --- a/people.json +++ b/people.json @@ -488,6 +488,10 @@ { "name": "james-yoo", "link": "./entries/markusde/james-yoo/run.sh" + }, + { + "name": "good-code-bad-code", + "link": "./entries/markusde/good-code-bad-code/run.sh" } ] }, -- cgit v1.2.3-70-g09d2