From 5831542e01209729390f5171d54f505b133ab47e Mon Sep 17 00:00:00 2001 From: elioat Date: Sun, 4 Dec 2022 15:16:52 -0500 Subject: re-org of rnd --- rnd/aoc01_partial.apl | 12 ------------ rnd/apl/aoc01_partial.apl | 12 ++++++++++++ rnd/gerbil/play.ss | 8 ++++++++ rnd/guile/play.scm | 24 ++++++++++++++++++++++++ rnd/play.ss | 8 -------- rnd/racket/sketch.rkt | 13 +++++++++++++ rnd/sketch.rkt | 13 ------------- 7 files changed, 57 insertions(+), 33 deletions(-) delete mode 100644 rnd/aoc01_partial.apl create mode 100644 rnd/apl/aoc01_partial.apl create mode 100644 rnd/gerbil/play.ss create mode 100644 rnd/guile/play.scm delete mode 100644 rnd/play.ss create mode 100644 rnd/racket/sketch.rkt delete mode 100644 rnd/sketch.rkt (limited to 'rnd') diff --git a/rnd/aoc01_partial.apl b/rnd/aoc01_partial.apl deleted file mode 100644 index 67d9984..0000000 --- a/rnd/aoc01_partial.apl +++ /dev/null @@ -1,12 +0,0 @@ -⍝ Look, I told myself I *wouldn't* do AoC 2022, -⍝ but work slack was too goddamned inticing, so -⍝ I'm not *really* doing it, but maybe some notes? - -⍝ I know nothing about file i/o in APL, so I'm just -⍝ ignoring that bit of the problem completely. - -⍝ This is the 2nd part for day 1 -- this sorts a -⍝ vector in descending order and sums the 1st 3 results - - vec ← 40 60 20 110 70 60 40 90 60 80 - +/vec[3↑⍒vec] diff --git a/rnd/apl/aoc01_partial.apl b/rnd/apl/aoc01_partial.apl new file mode 100644 index 0000000..67d9984 --- /dev/null +++ b/rnd/apl/aoc01_partial.apl @@ -0,0 +1,12 @@ +⍝ Look, I told myself I *wouldn't* do AoC 2022, +⍝ but work slack was too goddamned inticing, so +⍝ I'm not *really* doing it, but maybe some notes? + +⍝ I know nothing about file i/o in APL, so I'm just +⍝ ignoring that bit of the problem completely. + +⍝ This is the 2nd part for day 1 -- this sorts a +⍝ vector in descending order and sums the 1st 3 results + + vec ← 40 60 20 110 70 60 40 90 60 80 + +/vec[3↑⍒vec] diff --git a/rnd/gerbil/play.ss b/rnd/gerbil/play.ss new file mode 100644 index 0000000..7a7c3ca --- /dev/null +++ b/rnd/gerbil/play.ss @@ -0,0 +1,8 @@ +(import :std/net/request) + +(def req (http-get "pokeapi.co/api/v2/pokemon/ditto")) + +(request-status req) + +(display + (hash->list (request-json req))) diff --git a/rnd/guile/play.scm b/rnd/guile/play.scm new file mode 100644 index 0000000..92d5538 --- /dev/null +++ b/rnd/guile/play.scm @@ -0,0 +1,24 @@ +;;; Hello HTTP server +(use-modules + (web server) + (web request) + (web response) + (web uri)) + +(define (request-path-components request) + (split-and-decode-uri-path (uri-path (request-uri request)))) + +(define (hello-handler request body) + (if (equal? (request-path-components request) + '("banana")) + (values '((content-type . (text/plain))) + "banana kiwi apple pineapple watermelon grapefruit") + (not-found request))) + +(define (not-found request) + (values (build-response #:code 404) + (string-append "Resource not found: " + (uri->string (request-uri request))))) + + +(run-server hello-handler) diff --git a/rnd/play.ss b/rnd/play.ss deleted file mode 100644 index 7a7c3ca..0000000 --- a/rnd/play.ss +++ /dev/null @@ -1,8 +0,0 @@ -(import :std/net/request) - -(def req (http-get "pokeapi.co/api/v2/pokemon/ditto")) - -(request-status req) - -(display - (hash->list (request-json req))) diff --git a/rnd/racket/sketch.rkt b/rnd/racket/sketch.rkt new file mode 100644 index 0000000..dd25774 --- /dev/null +++ b/rnd/racket/sketch.rkt @@ -0,0 +1,13 @@ +#lang racket + +;; place for notes and tests and sketches and all that jazz + + +; the sketch of how maybe to access these nested hash tables (this has become hillariously difficult to solve) +; (define path '(some deep key)) -> + +; (for/fold ((ht deep-hash-table)) +; ((key (in-list path)) +; #:break +; (not (hash? ht))) +; (hash-ref ht key)) \ No newline at end of file diff --git a/rnd/sketch.rkt b/rnd/sketch.rkt deleted file mode 100644 index dd25774..0000000 --- a/rnd/sketch.rkt +++ /dev/null @@ -1,13 +0,0 @@ -#lang racket - -;; place for notes and tests and sketches and all that jazz - - -; the sketch of how maybe to access these nested hash tables (this has become hillariously difficult to solve) -; (define path '(some deep key)) -> - -; (for/fold ((ht deep-hash-table)) -; ((key (in-list path)) -; #:break -; (not (hash? ht))) -; (hash-ref ht key)) \ No newline at end of file -- cgit 1.4.1-2-gfad0