;; gc:fold
;; Applies a function to each element of the list,
;; threading an accumulator argument through the computation.
;;
;; Arguments
;; folder: function that updates the state with each element from the sequence.
;; If the input function is f and the elements are i0...iN then computes
;; (f ... (f s i0) ... iN)
;; state: initial state.
;; source: input list.
(defun gc:fold
(folder state source
/ f
) )
;; gc:reduce
;; Applies a function to each element of the list,
;; threading an accumulator argument through the computation.
;; Begin by applying the function to the first two elements.
;; Then feed this result into the function along with the third element and so on.
;; Return the final result.
;;
;; Arguments
;; reduction: function that takes in the current accumulated result and the next
;; element of the sequence to produce the next accumulated result.
;; source: input list.
(defun gc:reduce
(reduction source
) (gc:fold reduction
(car source
) (cdr source
)) )
;; gc:minBy
;; Returns the lowest of all elements of the list,
;; compared via < operator on the function result.
;;
;; Arguments
;; projection: function to transform items from the input sequence into comparable keys.
;; source: input list.
(defun gc:minBy
(projection source
) )
;; gc:maxBy
;; Returns the greatest of all elements of the list,
;; compared via > operator on the function result.
;;
;; Arguments
;; projection: function to transform items from the input sequence into comparable keys.
;; source: input list.
(defun gc:maxBy
(projection source
) )