about summary refs log tree commit diff
path: root/configs/shared/.emacs.d/wpc/enum.el
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2019-10-09T11·13+0100
committerWilliam Carroll <wpcarro@gmail.com>2019-12-24T15·21+0000
commit6b456c1b7a4f6899f063a6e65355af51901d9c7a (patch)
treecfc70d74818ae9fabdbbfb0cf16cce092e4c1a09 /configs/shared/.emacs.d/wpc/enum.el
parenta7c72adb2ebec1e497fc040eaf3551d564d61a5b (diff)
Massive configuration overhaul
Currently paying the price of months of non-diligent git usage.

Here's what has changed.

- Theming support in Gvcci and wpgtk
- Dropping support for i3
- Supporting EXWM
- Many Elisp modules
- Collapsed redundant directories in ./configs
Diffstat (limited to 'configs/shared/.emacs.d/wpc/enum.el')
-rw-r--r--configs/shared/.emacs.d/wpc/enum.el98
1 files changed, 98 insertions, 0 deletions
diff --git a/configs/shared/.emacs.d/wpc/enum.el b/configs/shared/.emacs.d/wpc/enum.el
new file mode 100644
index 000000000000..078e7972099c
--- /dev/null
+++ b/configs/shared/.emacs.d/wpc/enum.el
@@ -0,0 +1,98 @@
+;;; enum.el --- Enumerable protocol for Elisp -*- lexical-binding: t -*-
+;; Author: William Carroll <wpcarro@gmail.com>
+
+;;; Commentary:
+;; Heavily influenced by Elixir.
+
+;; I will not be implement every function in the Enum library, since I don't
+;; need every function.  Some of the streaming functionality may prove difficult
+;; to write in Elisp.  We shall see.
+
+;; TODO: Implement the following functions:
+;; - all?/2
+;; - any?/2
+;; - at/3
+;; - chunk_by/2
+;; - chunk_every/{2,3,4}
+;; - chunk_while/4
+;; - concat/1
+;; - concat/2
+;; - count/{1,2}
+;; - dedup/1 # prefer calling this function dedupe
+;; - dedup_by/2 # same as above
+;; - drop/2
+;; - drop_every/2
+;; - drop_while/2
+;; - each/2
+;; - empty?/1
+;; - fetch/2
+;; - fetch!/2
+;; - filter/2
+;; - find/3
+;; - find_index/2
+;; - find_value/3
+;; - flat_map/2
+;; - flat_map_reduce/3
+;; - group_by/3
+;; - intersperse/2
+;; - into/{2,3}
+;; - join/2
+;; - map/2
+;; - map_every/3
+;; - map_join/3
+;; - map_reduce/3
+;; - max/2
+;; - max_by/3
+;; - member?/2 # consider calling this contains?
+;; - min/2
+;; - min_by/2
+;; - min_max/2 # This is a great function because of O(n) time.
+;; - min_max_by/3
+;; - random/1 # Consider just sample with num=1
+;; - reduce/{2,3}
+;; - reduce_while/3
+;; - reject/2
+;; - reverse/{1,2}
+;; - reverse_slice/3
+;; - scan/{2,3}
+;; - shuffle/1
+;; - slice/{2,3}
+;; - sort/{1,2}
+;; - sort/2
+;; - sort_by/3
+;; - split/2
+;; - split_while/2
+;; - split_with/2
+;; - sum/1
+;; - take/2
+;; - take_every/2
+;; - take_random/2 # prefer calling this function sample
+;; - take_while/2
+;; - to_list/1
+;; - uniq/1 # prefer calling this unique
+;; - uniq_by/2 # prefer calling this unique-by
+;; - unzip/1
+;; - with_index/2
+;; - zip/{1,2}
+
+;; TODO: Consider how to handle dispatching by type.
+
+;; TODO: Which types should be supported herein?
+;; - linked-lists
+;; - associative-lists
+;; - cycles
+
+;; Warning: This module is a total work-in-progress, and it's quite possible
+;; that I may never even finish it.
+
+;;; Code:
+
+(defun enum/count (xs)
+  "Return the number of elements in `XS'."
+  (cond
+   ((alist/instance? xs) (alist/count xs))
+   ((list/instance?  xs) (list/length xs)))
+  )
+
+(provide 'enum)
+;;; enum.el ends here