mirror of
https://gitlab.com/vindarel/ciel.git
synced 2026-01-14 21:31:11 -08:00
147 lines
3.4 KiB
Org Mode
147 lines
3.4 KiB
Org Mode
|
||
Packages:
|
||
- =ciel=
|
||
- =ciel-user=: commodity.
|
||
- =generic-ciel=: uses [[https://github.com/alex-gutev/generic-cl/][generic-cl]] instead of =cl=.
|
||
|
||
* What is this ?
|
||
|
||
|
||
* generic-cl
|
||
|
||
TODO: contribute a defmethod example.
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
;; with a struct or class "point":
|
||
(defmethod equalp ((p1 point) (p2 point))
|
||
(…))
|
||
#+END_SRC
|
||
|
||
* Libraries
|
||
** Syntax extensions
|
||
*** Pythonic triple quotes docstring
|
||
|
||
https://github.com/smithzvk/pythonic-string-reader
|
||
|
||
We can use triple quotes for docstrings, and double quotes within them.
|
||
|
||
#+BEGIN_SRC lisp
|
||
(defun foo ()
|
||
"""foo "bar"."""
|
||
t)
|
||
#+end_src
|
||
*** Lambda shortcuts
|
||
|
||
https://github.com/windymelt/cl-punch/ - Scala-like anonymous lambda literal.
|
||
|
||
#+BEGIN_SRC lisp
|
||
;; ^() is converted into (lambda ...) .
|
||
;; Each underscore is converted into a lambda argument.
|
||
|
||
(mapcar ^(* 2 _) '(1 2 3 4 5))
|
||
;; => '(2 4 6 8 10)
|
||
|
||
;; One underscore corresponds one argument.
|
||
|
||
(^(* _ _) 2 3)
|
||
;; => 6
|
||
|
||
;; <_ reuses last argument.
|
||
|
||
(mapcar ^(if (oddp _) (* 2 <_) <_) '(1 2 3 4 5))
|
||
;; => '(2 2 6 4 10)
|
||
|
||
;; _! corresponds one argument but it is brought to top of the argument list.
|
||
;; It can be useful when you want to change argument order.
|
||
|
||
(^(cons _ _!) :a :b)
|
||
;; => (:b . :a)
|
||
|
||
(^(list _! _! _!) 1 2 3)
|
||
;; => '(3 2 1)
|
||
#+end_src
|
||
|
||
*** [TODO] cl-annot: Python-like annotations
|
||
|
||
https://github.com/m2ym/cl-annot
|
||
|
||
Without the slime helper, can't use it in the REPL ??
|
||
|
||
#+BEGIN_QUOTE
|
||
If you use Emacs, it is recommended to install misc/slime-annot.el
|
||
which contains some features of annotations. After locating
|
||
misc/slime-annot.el into your loadpath, write the following code into
|
||
your .emacs.
|
||
#+END_QUOTE
|
||
|
||
: (require 'slime-annot)
|
||
** Parsing numbers, floats, decimals
|
||
*** cl-decimals: parse and format decimal numbers
|
||
|
||
https://github.com/tlikonen/cl-decimals
|
||
|
||
The main interface are the functions =parse-decimal-number= and
|
||
=format-decimal-number=. The former is for parsing strings for decimal
|
||
numbers and the latter for pretty-printing them as strings.
|
||
|
||
Reading:
|
||
|
||
#+BEGIN_SRC lisp
|
||
DECIMALS> (parse-decimal-number "0.24")
|
||
6/25
|
||
|
||
|
||
DECIMALS> (parse-decimal-number "−12,345"
|
||
:decimal-separator #\,
|
||
:negative-sign #\−)
|
||
-2469/200
|
||
#+end_src
|
||
|
||
Parsing:
|
||
|
||
#+BEGIN_SRC lisp
|
||
DECIMALS> (format-decimal-number -100/6 :round-magnitude -3)
|
||
"-16.667"
|
||
("-" "16" "." "667")
|
||
|
||
DECIMALS> (loop for e from -5 upto 5
|
||
do (print (format-decimal-number
|
||
(expt 10 e) :round-magnitude -5
|
||
:decimal-separator ","
|
||
:integer-minimum-width 7
|
||
:integer-group-separator " "
|
||
:fractional-minimum-width 7
|
||
:fractional-group-separator " ")))
|
||
|
||
" 0,000 01"
|
||
" 0,000 1 "
|
||
" 0,001 "
|
||
" 0,01 "
|
||
" 0,1 "
|
||
" 1 "
|
||
" 10 "
|
||
" 100 "
|
||
" 1 000 "
|
||
" 10 000 "
|
||
"100 000 "
|
||
NIL
|
||
#+end_src
|
||
|
||
*** parse-number
|
||
https://github.com/sharplispers/parse-number
|
||
|
||
*** parse-float
|
||
https://github.com/soemraws/parse-float
|
||
** trivial-arguments
|
||
|
||
https://github.com/Shinmera/trivial-arguments
|
||
|
||
#+BEGIN_SRC emacs-lisp
|
||
(defun foo (a b c &optional d) nil)
|
||
(arglist #'foo)
|
||
;; (a b c &optional d)
|
||
#+END_SRC
|
||
|
||
* Rules
|
||
|
||
- don't install libraries that need a Slime helper to work in the REPL (cl-annot).
|