Created
September 9, 2011 17:59
-
-
Save sritchie/1206888 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (deffilterop [always-true [some-bool]] | |
| [x] | |
| (or some-bool true)) | |
| (?<- (stdout) | |
| [?value] | |
| ([[1]] ?value) | |
| (always-true [true] ?value)) | |
| RESULTS | |
| ----------------------- | |
| 1 true | |
| ----------------------- | |
| (?<- (stdout) | |
| [?value ?bool] | |
| ([[1]] ?value) | |
| (always-true [false] ?value :> ?bool)) | |
| RESULTS | |
| ----------------------- | |
| 1 false | |
| ----------------------- | |
| (?<- (stdout) | |
| [?value ?bool] | |
| ([[1]] ?value) | |
| (always-true [nil] ?value :> ?bool)) | |
| RESULTS | |
| ----------------------- | |
| 1 true | |
| ----------------------- | |
| ;; defmapcatop deals with this just fine | |
| (defmapcatop [always-returns [some-bool]] | |
| [x] | |
| (when (or some-bool true) | |
| [x])) | |
| (?<- (stdout) | |
| [?ret] | |
| ([[1]] ?value) | |
| (always-returns [false] ?value :> ?ret)) | |
| RESULTS | |
| ----------------------- | |
| 1 | |
| ----------------------- | |
| (?<- (stdout) | |
| [?ret] | |
| ([[1]] ?value) | |
| (always-returns [true] ?value :> ?ret)) | |
| RESULTS | |
| ----------------------- | |
| 1 | |
| ----------------------- | |
| ;; More funky stuff -- that println prints "false? true", which is what we want. | |
| ;; But the query still returns [1 false]. | |
| (deffilterop [always-true [some-bool]] | |
| [x] | |
| (println "false?" (= some-bool false)) | |
| (or some-bool true)) | |
| (?<- (stdout) | |
| [?value ?bool] | |
| ([[1]] ?value) | |
| (always-true [false] ?value :> ?bool)) | |
| RESULTS | |
| ----------------------- | |
| 1 false | |
| ----------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment