# The glyphs Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

# The glyphs Reference Manual

This is the glyphs Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Tue Jan 09 14:43:20 2018 GMT+0.

Next: , Previous: , Up: Top   [Contents][Index]

# glyphs

A little experiment in reducing verbosity in Common Lisp, inspired by BODOL (https://github.com/bodil/BODOL - no affiliation).

Update: Now that it's in quicklisp, simply:

``````(ql:quickload :glyphs)
``````

## Examples

### Factorial example with glyphs function macro:

glyphs:

``````(ƒ factorial
0 → 1
α → (* α (factorial (1- α))))
``````

vs.:

``````(defun factorial (x)
(cond ((equal x 0) 1)
(x (* x (factorial (1- x))))))
``````

result:

``````(factorial 8)
40320
``````

### Type safety with factorial

``````(ƒ factorial
0 → 1
(and (numberp α) (> α 0)) → (* α (factorial (1- α)))
α → (error "Non-numbers (or negatives) don't work real well with factorials!"))
``````

vs.:

``````(defun factorial (x)
(cond ((equal x 0) 1)
((and (numberp x) (> x 0)) (* x (factorial (1- x))))
(t (error "Non-numbers (or negatives) don't work real well with factorials!"))))
``````

### Built in type safety with factorial

``````(ƒ→ factorial (integer → integer)
0 → 1
α → (* α (factorial (1- α))))
``````

### Reverse a list

glyphs:

``````(ƒ reverse*
(cdr α) → (append (reverse* (cdr α)) `(,(car α)))
α → α)
``````

### Map with glyphs lambda macro to compare strings and do a side effect

glyphs:

``````(mapcar (λ "cat" → (print "Cats rock")
"dog" → (print "Dogs do too!")) '("cat" "dog" "mouse"))
``````

vs.:

``````(mapcar (lambda (x)
(cond ((equal x "cat") (print "Cats rock"))
((equal x "dog") (print "Dogs do too!")) '("cat" "dog" "mouse"))))
``````

result:

``````"Cats rock"
"Dogs do too!"
NIL
``````

## Comparison based on passed in conditionals

glyphs:

``````(ƒ double-odds-half-evens
(oddp α) → (* x 2)
(evenp α) → (/ x 2))
``````

vs.:

``````(defun double-odds-half-evens (x)
(cond ((oddp x) (* x 2))
((evenp x) (/ x 2))))
``````

result:

``````(double-odds-half-evens 4)
2
(double-odds-half-evens 3)
6
``````

### Using multiple values by including special variables in the statement

You can use multiple values by prefixing a variable in the statement portion of the code with either a 'α' or an '?'.

glyphs:

``````(mapcar (λ α → (+ α αb αc)) '(1 2 3) '(4 5 6) '(7 8 9))
``````

vs.:

``````(mapcar (lambda (a b c) (+ a b c)) '(1 2 3) '(4 5 6) '(7 8 9))
``````

result:

``````(12 15 18)
``````

## Fast matching based on regex strings

Make sure to use the readtable that comes with it first:

``````(in-readtable glyphs:syntax)
``````

Or these little readtable shortcuts will not work.

glyphs:

``````(ƒ any-cats?
~"cat"~ → (print "yes!"))
``````

vs.:

``````(defun any-cats? (x)
(when (cl-ppcre:scan "cat" x)
(print "yes!")))
``````

result:

``````(any-cats? "I see some cats")
"yes!"
``````

## Easy regex replaces on matching strings

glyphs:

``````(ƒ no-cats
~"(were|cat)"~ → |"dog"|)
``````

vs.:

``````(defun no-cats (x)
(let ((regex "(were|cat)"))
(when (cl-ppcre:scan regex x)
(cl-ppcre:regex-replace-all regex x "dog"))))
``````

result:

``````(no-cats "there were dogs and there were cats")
"there dog dogs and there dog dogs"
``````

# Currently used glyphs and bindings for them (more to come)

## Emacs bindings

``````;; Keybindings for glyphs
(global-set-key (kbd "M-l") (lambda () (interactive) (insert "\u03bb"))) ; λ lambda
(global-set-key (kbd "M-f") (lambda () (interactive) (insert "\u0192"))) ; ƒ function
(global-set-key (kbd "M--") (lambda () (interactive) (insert "\u2192"))) ; → right arrow
(global-set-key (kbd "M-a") (lambda () (interactive) (insert "\u03b1"))) ; α alpha
(global-set-key (kbd "M-y") (lambda () (interactive) (insert "\u03c8"))) ; ψ psi
``````

## Vim bindings

``````" Keybindings for glyphs
:inoremap <A-l> <C-v>u3bb<Space>   ; λ lambda
:inoremap <A-f> <C-v>u192<Space>   ; ƒ function
:inoremap <A--> <C-v>u2192<Space>  ; → right arrow
:inoremap <A-a> <C-v>u03b1<Space>  ; α alpha
:inoremap <A-y> <C-v>u03c8<Space>  ; ψ psi
``````

## Mac OS X keybindings

``````{
"~l" = ("insertText:", "\U03BB"); /* alt + l ~> λ lambda */
"~f" = ("insertText:", "\U0192"); /* alt + f ~> ƒ function */
"~-" = ("insertText:", "\U2192"); /* alt + - ~> → right arrow */
"~a" = ("insertText:", "\U03b1"); /* alt + a ~> α alpha */
"~y" = ("insertText:", "\U03c8"); /* alt + y ~> ψ psi */
}
``````

## StumpWM keybindings

``````(defmacro defkeys-top (&rest keys)
(let ((ks (mapcar #'(lambda (k) (cons 'defkey-top k)) keys)))
`(progn ,@ks)))

(defcommand xdo-lambda () ()
(run-shell-command "xdotool type λ"))
(defcommand xdo-fn () ()
(run-shell-command "xdotool type ƒ"))
(defcommand xdo-alpha () ()
(run-shell-command "xdotool type α"))
(defcommand xdo-arrow () ()
(run-shell-command "xdotool type →"))

(defkeys-top
("s-l" "xdo-lambda")
("s-f" "xdo-fn")
("s--" "xdo-arrow")
("s-a" "xdo-alpha"))
``````

If you're absolutely opposed to non-asc

Next: , Previous: , Up: Top   [Contents][Index]

## 2 Systems

The main system appears first, followed by any subsystem dependency.

Previous: , Up: Systems   [Contents][Index]

### 2.1 glyphs

Author

Matthew Carter <m@ahungry.com>

GPLv3

Description

Glyphs to reduce Common Lisp verbosity

Dependencies
• cl-ppcre
• parenscript
Source

glyphs.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

## 3 Files

Files are sorted by type and then listed depth-first from the systems components trees.

Previous: , Up: Files   [Contents][Index]

### 3.1 Lisp

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.1 glyphs.asd

Location

glyphs.asd

Systems

glyphs (system)

Next: , Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.2 glyphs/package.lisp

Parent

glyphs (system)

Location

package.lisp

Packages

Previous: , Up: Lisp files   [Contents][Index]

#### 3.1.3 glyphs/glyphs.lisp

Dependency

package.lisp (file)

Parent

glyphs (system)

Location

glyphs.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

## 4 Packages

Packages are listed by definition order.

Previous: , Up: Packages   [Contents][Index]

### 4.1 glyphs

Source

package.lisp (file)

Use List
• parenscript
• cl-ppcre
• common-lisp
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

## 5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.

Next: , Previous: , Up: Definitions   [Contents][Index]

### 5.1 Exported definitions

Next: , Previous: , Up: Exported definitions   [Contents][Index]

#### 5.1.1 Special variables

Special Variable: *ψ*
Package
Source

glyphs.lisp (file)

Previous: , Up: Exported definitions   [Contents][Index]

#### 5.1.2 Macros

Macro: ± A B
Package
Source

glyphs.lisp (file)

Macro: ƒ NAME &rest REST

Similar to defun, requires using x as the default case

Package
Source

glyphs.lisp (file)

Macro: ƒƒ NAME &rest REST

PS - Similar to defun, requires using x as the default case

Package
Source

glyphs.lisp (file)

Macro: ƒ→ NAME TYPES &rest REST

Similar to defun, requires using α as the default case. Includes the type safety of defn.

Package
Source

glyphs.lisp (file)

Macro: λ &rest REST

Similar to lambda, requires using x as the default case

Package
Source

glyphs.lisp (file)

Macro: λλ &rest REST

PS - Similar to lambda, requires using x as the default case

Package
Source

glyphs.lisp (file)

Macro: ψ DATA &rest REST

Shortcut for a mapcar with the short lambda stuff

Package
Source

glyphs.lisp (file)

Previous: , Up: Definitions   [Contents][Index]

### 5.2 Internal definitions

Next: , Previous: , Up: Internal definitions   [Contents][Index]

#### 5.2.1 Macros

Macro: /. &rest REST
Package
Source

glyphs.lisp (file)

Macro: /./. &rest REST
Package
Source

glyphs.lisp (file)

Macro: arg-walker &rest ARGS
Package
Source

glyphs.lisp (file)

Macro: defn NAME TYPES ARGS &rest REST

Type safe defun

Package
Source

glyphs.lisp (file)

Macro: ff &rest REST
Package
Source

glyphs.lisp (file)

Macro: pm NAME ARGS &rest REST
Package
Source

glyphs.lisp (file)

Previous: , Up: Internal definitions   [Contents][Index]

#### 5.2.2 Functions

Function: flatten STRUCTURE
Package
Source

glyphs.lisp (file)

Function: greplace STREAM CHAR
Package
Source

glyphs.lisp (file)

Function: gscan STREAM CHAR
Package
Source

glyphs.lisp (file)

Previous: , Up: Top   [Contents][Index]

## Appendix A Indexes

Next: , Previous: , Up: Indexes   [Contents][Index]

### A.1 Concepts

Next: , Previous: , Up: Indexes   [Contents][Index]

### A.2 Functions

Jump to: /   ±   A   D   F   G   M   P   Ƒ   Λ   Ψ
Jump to: /   ±   A   D   F   G   M   P   Ƒ   Λ   Ψ

Next: , Previous: , Up: Indexes   [Contents][Index]

### A.3 Variables

Index Entry Section `*ψ*`: Exported special variables `Special Variable, *ψ*`: Exported special variables
Index Entry Section `glyphs`: The glyphs system `glyphs`: The glyphs package `Package, glyphs`: The glyphs package `System, glyphs`: The glyphs system