Back
struct (clj)
(source)function
(struct s & vals)
Returns a new structmap instance with the keys of the
structure-basis. vals must be supplied for basis keys in order -
where values are not supplied they will default to nil.
Examples
cognitect-labs/aws-api
(ns dynamodb-examples
(:require [clojure.core.async :as a]
[clojure.java.io :as io]
[clojure.data.json :as json]
[cognitect.aws.client.api :as aws]))
(let [ ;; The aws-supplied example data are all json. We can use them
;; as/is, but we need keys defined the input specs to be
;; keywords if we want to validate the structure first!
xform-specified-keys
(fn [k]
(get (reduce (fn [a v] (assoc a v (keyword v)))
{}
["B" "BOOL" "BS" "Item" "L" "M" "N" "NS" "NULL" "PutRequest" "S" "SS"])
k
k))]
(->> ["Forum.json"
"Reply.json"
"Thread.json"]
(map #(-> (io/file "examples" "resources" "dynamodb" %)
slurp
(json/read-str :key-fn xform-specified-keys)))
(map #(aws/invoke ddb {:op :BatchWriteItem
:request {:RequestItems %}}))))
hraberg/deuce
(ns deuce.emacs.casetab
(:use [deuce.emacs-lisp :only (defun defvar)])
(:require [clojure.core :as c]
[deuce.emacs.chartab :as chartab]
[deuce.emacs.data :as data]
[deuce.emacs.fns :as fns])
(:import [deuce.emacs.data CharTable])
(:refer-clojure :exclude []))
(defun case-table-p (object)
"Return t if OBJECT is a case table.
See `set-case-table' for more information on these data structures."
(and (data/char-table-p object) (= 'case-table (.purpose ^CharTable object))))
hraberg/deuce
(ns deuce.emacs.floatfns
(:use [deuce.emacs-lisp :only (defun defvar)])
(:require [clojure.core :as c]
[deuce.emacs.alloc :as alloc])
(:refer-clojure :exclude [float]))
(defun ldexp (sgnfcand &optional exponent)
"Construct number X from significand SGNFCAND and exponent EXP.
Returns the floating point value resulting from multiplying SGNFCAND
(the significand) by 2 raised to the power of EXP (the exponent)."
(* (Math/pow 2 (or exponent 1)) sgnfcand))
hraberg/deuce
(ns deuce.emacs.print
(:use [deuce.emacs-lisp :only (defun defvar)])
(:require [clojure.core :as c]
[clojure.string :as s]
[deuce.emacs.buffer :as buffer]
[deuce.emacs.data :as data]
[deuce.emacs.editfns :as editfns]
[deuce.emacs.fns :as fns])
(:refer-clojure :exclude [print]))
(defvar print-circle nil
"*Non-nil means print recursive structures using #N= and #N# syntax.
If nil, printing proceeds recursively and may lead to
`max-lisp-eval-depth' being exceeded or an error may occur:
\"Apparently circular structure being printed.\" Also see
`print-length' and `print-level'.
If non-nil, shared substructures anywhere in the structure are printed
with `#N=' before the first occurrence (in the order of the print
representation) and `#N#' in place of each subsequent occurrence,
where N is a positive decimal integer.")
(defvar print-gensym nil
"Non-nil means print uninterned symbols so they will read as uninterned.
I.e., the value of (make-symbol \"foobar\") prints as #:foobar.
When the uninterned symbol appears within a recursive data structure,
and the symbol appears more than once, in addition use the #N# and #N=
constructs as needed, so that multiple references to the same symbol are
shared once again when the text is read back.")
When you bind `print-continuous-numbering' to t, you should probably
also bind `print-number-table' to nil. This ensures that the value of
`print-number-table' can be garbage-collected once the printing is
done. If all elements of `print-number-table' are nil, it means that
the printing done so far has not found any shared structure or objects
that need to be recorded in the table.")
(defun error-message-string (obj)
"Convert an error value (ERROR-SYMBOL . DATA) to an error message.
See Info anchor `(elisp)Definition of signal' for some details on how this
error message is constructed."
(let [error-symbol (data/car obj)
data (data/cdr obj)]
(str (or (fns/get error-symbol 'error-message)
(s/capitalize (s/join " " (s/split (str error-symbol) #"-"))))
(when (and (data/listp data) (not (nil? data)))
(str ": " (s/join ", " (map pr-str data)))))))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
"Type annotations for the base Clojure distribution."
#?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
(:require [clojure.core :as cc]
[typed.clojure :as t]
#?(:clj [typed.ann-macros.clojure :as macros])
#?(:clj typed.ann.clojure.jvm) ;; jvm annotations
#?(:clj clojure.core.typed))
#?(:clj
(:import (clojure.lang PersistentHashSet PersistentList
APersistentMap #_IPersistentCollection
#_ITransientSet
IRef)
(java.util Comparator Collection))))
(macros/anns
#?@(:cljs [] :default [
;; Internal annotations
;clojure.core.typed.current-impl/*current-impl* t/Any
clojure.core.typed.current-impl/clojure t/Any
clojure.core.typed.current-impl/clojurescript t/Any
clojure.core.typed/ann* [t/Any t/Any t/Any :-> t/Any]
clojure.core.typed/untyped-var* [t/Any t/Any :-> t/Any]
clojure.core.typed/declare-names* [t/Any :-> t/Any]
clojure.core.typed/typed-deps* [t/Any :-> t/Any]
clojure.core.typed/warn-on-unannotated-vars* [:-> t/Any]
clojure.core.typed/ann-datatype* [t/Any t/Any t/Any t/Any :-> t/Any]
clojure.core.typed/ann-protocol* [t/Any t/Any t/Any :-> t/Any]
clojure.core.typed/ann-record* [t/Any t/Any t/Any t/Any :-> t/Any]
clojure.core.typed/ann-pdatatype* [t/Any t/Any t/Any t/Any :-> t/Any]
clojure.core.typed/declare-datatypes* [t/Any :-> t/Any]
clojure.core.typed/declare-protocols* [t/Any :-> t/Any]
clojure.core.typed/non-nil-return* [t/Any t/Any :-> t/Any]
clojure.core.typed/nilable-param* [t/Any t/Any :-> t/Any]
clojure.core.typed/override-constructor* [t/Any t/Any :-> t/Any]
clojure.core.typed/override-method* [t/Any t/Any :-> t/Any]
clojure.core.typed/typed-deps* [t/Any :-> t/Any]
clojure.core.typed/load-if-needed [:-> t/Any]
clojure.core.typed/*collect-on-eval* t/Any
])
cc/create-struct [t/Any :* :-> (t/Map t/Any t/Any)]
])
cc/method-sig [java.lang.reflect.Method :-> '[t/Any t/AnyNilableNonEmptySeq t/Any]]
cc/proxy-name [Class (t/Seqable Class) :-> t/Str]
cc/get-proxy-class [Class :* :-> Class]
cc/construct-proxy [Class t/Any :* :-> t/Any]
cc/init-proxy [t/Proxy (t/Map t/Str t/Any) :-> t/Proxy]
cc/update-proxy [t/Proxy (t/Map t/Str t/Any) :-> t/Proxy]
cc/proxy-mappings [t/Proxy :-> (t/Map t/Str t/Any)]
cc/proxy-call-with-super (t/All [x] [[:-> x] t/Proxy t/Str :-> x])
cc/bean [Object :-> (t/Map t/Any t/Any)]
])
#?@(:cljs [] :default [
cc/seq-to-map-for-destructuring [t/AnySeqable :-> t/Any]
;cc/seq-to-map-for-destructuring (t/All [x] (t/IFn [(t/HSeq [x]) :-> x]
; ;; could be anything if seq is of count 1
; [(t/Seq t/Any) :-> t/Any]))
cc/destructure [t/Any :-> t/Any]
])