Elisp datatypes

From wikinotes

Lisp is dynamically typed, a variable can contain any type of value. It's type is determined by the contents.

Basics

Variable Scope

(defvar my_variable "my_variable_value")  ;; ?
(setq   my_variable "my_variable_value")  ;; define global variable

Docstring

(defvar my_variable "my_variable_value"	"my_variable docstring")  ;; define variable with docstring
(documentation-property 'my_variable 'variable-documentation)     ;; print variable docstring

Type Conversion

(string-to-number "4")
(number-to-string 3 )

Boolean

nil == () == false
anything else == true

String

Numbers

Dictionaries

;; create dict
(setq my_dict '( (a . 1) (b . 2) (c . 3) ))  

;; remove key from dict
(setq my_dict (delq  (assoc 'a var)  var ))

;; value of 'a' in my_dict
(cdr (assoc 'a var))

;; add new key/value to my_dict
(add-to-list 'my_dict '(d 10))