Skip to content

Commit ce70d11

Browse files
Merge pull request #477 from tie-rack/more-docstrings
Add a few more docstrings
2 parents cdeacc8 + 91309e8 commit ce70d11

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

pixie/stdlib.pxi

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,6 +2245,11 @@ user => (refer 'pixie.string :exclude '(substring))"
22452245

22462246

22472247
(defn merge-with
2248+
{:doc "Returns a map consisting of each map merged onto the first. If a
2249+
map contains a key that already exists in the result, the
2250+
value will be f applied to the value in the result map and
2251+
the value from the map being merged in."
2252+
:examples [["(merge-with + {:a 1 :b 2} {:a 3 :c 5} {:c 3 :d 4})" nil {:a 4, :b 2, :c 8 :d 4}]]}
22482253
[f & maps]
22492254
(cond
22502255
(empty? maps) nil
@@ -2570,24 +2575,29 @@ Expands to calls to `extend-type`."
25702575
(into () coll))
25712576

25722577
(defmacro use
2578+
"Loads a namespace and refers all symbols from it."
25732579
[ns]
25742580
`(do
25752581
(load-ns ~ns)
25762582
(refer ~ns :refer :all)))
25772583

25782584
(defn count-rf
2579-
"A Reducing function that counts the items reduced over"
2585+
"A Reducing function that counts the items reduced over."
25802586
([] 0)
25812587
([result] result)
25822588
([result _] (inc result)))
25832589

25842590
(defn dispose!
2585-
"Finalizes use of the object by cleaning up resources used by the object"
2591+
"Finalizes use of the object by cleaning up resources used by the object."
25862592
[x]
25872593
(-dispose! x)
25882594
nil)
25892595

2590-
(defmacro using [bindings & body]
2596+
(defmacro using
2597+
"Evaluates body with the bindings available as with let,
2598+
calling -dispose! on each name afterwards. Returns the value of the
2599+
last expression in body."
2600+
[bindings & body]
25912601
(let [pairs (partition 2 bindings)
25922602
names (map first pairs)]
25932603
`(let [~@bindings
@@ -2653,6 +2663,8 @@ Calling this function on something that is not ISeqable returns a seq with that
26532663
{} m))
26542664

26552665
(defn mapv
2666+
{:doc "Returns a vector consisting of f applied to each element in col."
2667+
:examples [["(mapv inc '(1 2 3))" nil [2 3 4]]]}
26562668
([f col]
26572669
(transduce (map f) conj col)))
26582670

@@ -2687,7 +2699,10 @@ Calling this function on something that is not ISeqable returns a seq with that
26872699

26882700
(def hash-map hashmap)
26892701

2690-
(defn zipmap [a b]
2702+
(defn zipmap
2703+
"Returns a map with the elements of a mapped to the corresponding
2704+
elements of b."
2705+
[a b]
26912706
(into {} (map vector a b)))
26922707

26932708
(extend -str Environment
@@ -2775,6 +2790,7 @@ Calling this function on something that is not ISeqable returns a seq with that
27752790

27762791

27772792
(defn bool?
2793+
"Returns true if x is a Bool."
27782794
[x]
27792795
(instance? Bool x))
27802796

@@ -2891,7 +2907,8 @@ Calling this function on something that is not ISeqable returns a seq with that
28912907

28922908
(defprotocol IComparable
28932909
(-compare [x y]
2894-
"Compare to objects returing 0 if the same -1 with x is logically smaller than y and 1 if x is logically larger."))
2910+
"Compares two objects. Returns 0 when x is equal to y, -1 when x
2911+
is logically smaller than y, and 1 when x is logically larger."))
28952912

28962913
(defn compare-numbers
28972914
[x y]
@@ -2981,6 +2998,9 @@ Calling this function on something that is not ISeqable returns a seq with that
29812998
(throw [::ComparisonError (str "Cannot compare: " x " to " y)]))))
29822999

29833000
(defn compare
3001+
"Compares two objects. Returns 0 when x is equal to y, -1 when x is
3002+
logically smaller than y, and 1 when x is logically larger. x must
3003+
implement IComparable."
29843004
[x y]
29853005
(if (satisfies? IComparable x)
29863006
(-compare x y)

0 commit comments

Comments
 (0)