-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
awb99
committed
Apr 18, 2024
1 parent
c547756
commit 59c229c
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(ns demo.notebook.pprint | ||
(:require | ||
[cljs.pprint :refer [print-table]])) | ||
|
||
(print-table [{:name "Harry" :age "?"} | ||
{:name "Dumbeldor" :age "old"}]) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{:name "cljs-pprint" | ||
; build | ||
:lazy true | ||
:cljs-namespace [goldly.pprint] | ||
:cljs-ns-bindings {cljs.pprint goldly.pprint/pprint-namespace}} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(ns goldly.pprint | ||
(:require | ||
[cljs.pprint :as pp] | ||
[sci.core :as sci])) | ||
|
||
(defn pprint [& args] | ||
(binding [*print-fn* @sci/print-fn] | ||
(apply pp/pprint args))) | ||
|
||
(defn print-table [& args] | ||
(binding [*print-fn* @sci/print-fn] | ||
(apply pp/print-table args))) | ||
|
||
(def pns (sci/create-ns 'cljs.pprint nil)) | ||
|
||
(def pprint-namespace | ||
{'pprint (sci/copy-var pprint pns) | ||
'print-table (sci/copy-var print-table pns)}) | ||
|
||
; {:namespaces {'cljs.pprint pprint-namespace}} | ||
|
||
; (:require [cljs.pprint :as pprint])) | ||
; (pprint/cl-format nil "~,2f" 1.2345) ; => returns "1.23" | ||
; (pprint/cl-format true "~,2f" 1.2345) ; => prints "1.23", returns nil |