Skip to content

Clojure Inspectorλ︎

A visual browser for Clojure data using the Java UI libraries.

Require the clojure.inspector namespace in the REPL or project namespace definitions to use the functions

(require '[clojure.inspector :as inspector])
(ns practicalli.application
  (:require [clojure.inspector :as inspector]))
  • inspect for flat data structures
  • inspect-tree for deeply nested / hierarchically data
  • inspect-table a sequence of data structures with the same shape

inspectλ︎

View flat structures especially with non-trivial size data sets.

This example generated 10,000 random numbers. The Clojure inspector shows the values along with their index in the collection.

(inspector/inspect
  (repeatedly 10000 #(rand-int 101)))

Clojure Inspector - inspect data elements with index

inspect-treeλ︎

(inspect
  {:star-wars
    {:characters
      {:jedi ["obiwan kenobi" "Yoda" "Master Wendoo"]
       :sith ["Palpatine" "Count Dukoo"]}}})

Clojure - Inspector - inspect tree with hash-map

inspect-tableλ︎

Inspect a sequence of data structures that share the same form, often found in data sets for machine learning and wider data science, eg. daily weather records.

This example generates mock data for a 20 day period for one or more locations. Each day contains the day, location and cumulative number of cases reported.

(defn mock-data-set
  "Generates a set of mock data for each name
  Arguments: names as strings, names used in keys
  Returns: Sequence of maps, each representing confirmed cases"
  [& locations]
  (for [location locations
        day      (range 20)]
    {:day      day
     :location location
     :cases    (+ (Math/pow (* day (count location)) 0.8)
                  (rand-int (count location)))}))

(inspector/inspect-table
  (mock-data-set "England" "Scotland" "Wales" "Northern Ireland"))

Cider Inspector - inspect table - medical cases mock data