Created
December 12, 2023 04:48
-
-
Save darius/e7772893548fed68a911a42c6373cdcb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Issues: | |
;; - Different behavior on ragged arguments, zip vs. transpose. How to resolve? | |
;; - Have to handle when the arguments don't match on operator | |
;; - Add methods for .ragged, .pad-left, .pad-right | |
;; We can avoid a 2x2 table of what to do here if we have methods to | |
;; deal with terms and lists in a unified way. | |
;; Currently: | |
;; - term: term<-, term.tag, term.parts | |
;; - list: itself, N/A, itself | |
;; We could use: | |
;; - (term.maker parts) -> a term with the same tag and the new parts | |
;; - (list.maker parts) -> parts, perhaps with a different concrete type? | |
;; - list.parts -> list.values | |
;; - list.type-predicate | |
;; - term.tag-predicate hmmm | |
;; Different though: no list.tag, different (~ x) method | |
;; Don't want them too substitutable, or we wouldn't have different types. So... | |
(to (new-transpose data) | |
(to (typify thing) | |
(if (term? thing) | |
(~ (on (x) (and (term? x) (= x.tag thing.tag))) | |
~.parts | |
(on (args) (term<- thing.tag args))) | |
(~ (on (x) (not (term? x))) ;; best we can do | |
itself | |
itself))) | |
(let (~ outer-type? outer-parts outer-maker) (typify data)) | |
(let inners (outer-parts data)) | |
(hm (if inners.none? data) ;; Hm, kinda questionable there's any answer in this case. | |
(else | |
(let (~ inner-type? inner-parts inner-maker) (typify inners.first)) | |
(surely (every inner-type? inners.rest)) | |
(inner-maker (do flipping [(rows (each inner-parts inners))] | |
(if (every ~.none? rows) | |
'() | |
(link (outer-maker (each ~.first rows)) | |
(flipping (each ~.rest rows))))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment