Common Lisp -Easy edit files from the REPL with ed (SBCL and others)

So you are playing around with the REPL and want to edit a file without firing up the Emacs beast. Emacs is the notorious wall beginners hit when learning Common Lisp.

No need to tackle all the challenges at once! In SBCL, my implementation of choice, configuring ED is painful.

There are mailing list instructions and this ( i might update at some point with actual URLs. Still painful).

No fear, there is an easier way!

just follow the instructions and install Magic (ed) https://github.com/sanel/magic-ed

Then you can simply edit in the repl with

(ed “your-file-name.lisp”)

 

Useful Common Lisp Resources

Common Lisp minispec

https://lamberta.github.io/minispec/

Common Lisp Hints

http://n-a-n-o.com/lisp/cmucl-tutorials/LISP-tutorial.html#toc4

SICP (partially ) done in Common Lisp

https://eli.thegreenplace.net/tag/sicp

Notes on Graham’s ANSI Common Lisp

https://courses.cs.northwestern.edu/325/readings/readings.php#setup

MIT intro to dev tools

https://missing.csail.mit.edu/

Roots of Lisp

Partial Summary of Paul Graham’s essay on the 1960 McCarthy’s Lisp

http://www.paulgraham.com/rootsoflisp.html

Seven primitive operators:

quote, atom, eq, car, cdr, cons, cond

Expression  : 
foo
()
(foo)
(foo bar)
(a b (c) d)

 

  1. (quote x) returns x. Abbreviated as ‘x
  2. (atom ‘a) – predicate,  returns T if true, () if False  (Nil)
  3. (eq x y)  – returns T if  atoms x=y, or two empty lists, otherwise returns ()
  4. (car x) expects x to be a list, and returns the first element.
  5. (cdr x) expects x to be a list, and returns everything after the first element
  6. (cons  x y) expects the value of y to be a list, and returns a list containing the value of x followed by the elements of the value of y.
  7. (cond (p1 e1) … (pn en)) is evaluated as follows. The p expressions are evaluated in order until one returns T, true. When one is found, the value of the corresponding e expression is returned as the value of the whole cond expression.

 

Further reading:

See McCarthy eval Lisp on github   based on the 1.5 manual 

Also, this PG version https://gist.github.com/bsima/7d52b805996e60fa5832

And this: http://informatimago.com/develop/lisp/com/informatimago/small-cl-pgms/aim-8/aim-8.lisp

another useful doc

Numbers can be implemented by using a list of n atoms to represent the number n.

See “The Art of The Interpreter”  by Steele and Sussman  for an examination of “effects of various language design decisions on theprogramming styles available to a user of the language, with particular emphasis on the ability to incrementally construct modular systems.”

https://dspace.mit.edu/handle/1721.1/6094

 

Common Lisp operators

I  looked up the list of CL operators in the HyperSpec, as selected by Paul Graham in his book ANSI Common Lisp

apply      apply function &rest args+ => result*        http://clhs.lisp.se/Body/f_apply.htm

(setq f ‘+) => +
(apply f ‘(1 2)) => 3

aref Accessor AREF  aref array &rest subscripts => element http://clhs.lisp.se/Body/f_aref.htm

(aref (setq alpha (make-array 4)) 3) => implementation-dependent
(setf (aref alpha 3) ‘sirens) => SIRENS
(aref alpha 3) => SIRENS

backquote  (`) The backquote introduces a template of a data structure to be built. Spec

`(cond ((numberp ,x) ,@y) (t (print ,x) ,@y))
is roughly equivalent to writing
(list ‘cond
(cons (list ‘numberp x) y)
(list* ‘t (list ‘print x) y))

block      block name form* => result*Spec 

(block whocares (values 1 2) (values 3 4)) => 3, 4

ceiling   

ceiling and fceiling produce a quotient that has been truncated toward positive infinity; that is, the quotient represents the smallest mathematical integer that is not smaller than the mathematical result.  http://www.lispworks.com/documentation/HyperSpec/Body/f_floorc.htm

(floor 3/2) => 1, 1/2
(ceiling 3 2) => 2, -1

char= 

cons

defmacro

documentation   

eq  eq x y => generalized-boolean  http://clhs.lisp.se/Body/f_eq.htm

(eq ‘a ‘b) => false
(eq ‘a ‘a) => true
(eq 3 3)
=> true

error error datum &rest arguments =>| http://clhs.lisp.se/Body/f_error.htm

(cond ((or (not (typep x ‘integer)) (minusp x))
(error “~S is not a valid argument to FACTORIAL.” x))

expt / exp         Spec perform exponentiation. exp returns e raised to the power number, where e is the base of the natural logarithms. exp has no branch cut. expt returns base-number raised to the power power-number.

(exp 0) => 1.0
(exp 1) => 2.718282
(exp (log 5)) => 5.0
(expt 2 8) => 256

fdefenition 

function 

floor see ceiling

gensym   spec 
get-setf-expansion spec

if 

imagpart 

labels 

length 

multiple-value-bind 
nth-value 

quote 

realpart 

symbol-function 

tagbody 

type-of 

typep 

 aref backquote block car cdr ceiling char= cons defmacro
documentation eq error expt fdefinition function floor gensym
        get-setf-expansion if imagpart labels length multiple-value-bind
        nth-value quote realpart symbol-function tagbody type-of typep

CL -Common Lisp, SLY and Doom Emacs

Getting Common Lisp to Work in Doom Emacs

 

  1. uncomment, removing the two ;; , from common-lisp in ~/.doom.d/init.el

 

2.

(setq common-lisp-hyperspec-root
;; “http://www.lispworks.com/reference/HyperSpec/”)
“file:///home/username/lisp/HyperSpec/”)
(setq browse-url-browser-function ‘eww-browse-url)
(setq common-lisp-hyperspec-symbol-table “/home/username/lisp/HyperSpec/Data/Map_S ym.txt”)
;; block images in EWW browser
(setq-default shr-inhibit-images t)

SICP self-study notes

Running scheme – install DrRacket and sicp package 

Modern online book version

https://github.com/sarabander/sicp Epub and other info

https://sarabander.github.io/sicp/ HTML version

solutions: https://github.com/sarabander/p2pu-sicp

DO the ex yourself first. Also, try the interactive version 

Suggested Study process:

  • Flip through the chapter
  • Read the lecture notes (for ex. here  or here,  PDF )
  • Watch the video
  • Review chapter
  • Do the exercises

Also, see this plan https://github.com/abrantesasf/sicp-abrantes-study-guide

Lectures:

https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/

MIT page https://mitpress.mit.edu/sites/default/files/sicp/index.html

Alternative lectures https://www.youtube.com/watch?v=4leZ1Ca4f0g&list=PLhMnuBfGeCDNgVzLPxF9o5UNKG1b-LFY9

Other:

https://functionalcs.github.io/curriculum/

https://teachyourselfcs.com/

https://thevaluable.dev/learning-computer-science-software-developer/

Learn Lisp in 2019

Summary: On GNU/Linux install  SBCL http://www.sbcl.org/

For editors, if You want a “classic” visual IDE, go with Atom or Eclipse, otherwise you can use implementations such as Emacs or Vim, see the road to common Lisp guide.

For books, if You have a compsci background, go with Structure and Implementation of Computer Programs, otherwise choose Common Lisp: A Gentle Introduction to Symbolic Computation

https://www.cs.cmu.edu/~dst/LispBook/

Good starter guide – road to common Lisp

http://stevelosh.com/blog/2018/08/a-road-to-common-lisp/

Lisp in Small Parts

http://lisp.plasticki.com/show?14F

Practical Common Lisp

http://www.gigamonkeys.com/book/

Common Lisp Cookbook

https://lispcookbook.github.io/cl-cookbook/

Structure and Implementation of Computer Programs (book, free online )

https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book.html

The book uses Scheme

https://www.gnu.org/software/mit-scheme/

Free Basic Online Lisp Course

http://art2.ph-freiburg.de/Lisp-Course

Lisp Quick Start

https://cs.gmu.edu/~sean/lisp/LispTutorial.html

Comparison chart for Lisp: Common Lisp, Racket, Clojure, Emacs Lisp

http://hyperpolyglot.org/lisp

Common Lisp Hints

http://n-a-n-o.com/lisp/cmucl-tutorials/LISP-tutorial.html#toc5

Lisp Koans

https://github.com/google/lisp-koans

Reddit Lisp community

https://www.reddit.com/r/lisp/

 

Metrics in Scrum

Measuring “success” in Scrum

  1. Working Software ( stuff gets shipped ) “Working software is the primary measure of progress” . [ Manifesto ]
  2. Sustainable ( = continious ) development. Developers don’t quit, don’t ask to change teams, don’t claim multiple granny funerals.
  3. Extra – four key metrics to support software delivery performance: lead time, deployment frequency, mean time to restore (MTTR), and change fail percentage. ( time to deploy, how often deploys happen, backup time, how many times deploys fail ) GoCD https://www.gocd.org/
  4. Predictability – delivering over 90% of commitments,

  5. story acceptance rate, defect rate – tracking acceptance ( can track bug life as well)

  6. HEART framework – Happiness, Engagement, Adoption, Retention, Task Success safe.pngheart2.jpg

The Dark Side of Work Perks

Interesting article on work perks and what they really mean for employees.

Free food encourages people to:

  • work longer hours,
  • exchange ideas,
  • saves time,
  • imposes lifestyle creep and creates a competitive advantage as employees considering changing jobs must consider either preparing their own lunch or lunch available in the vicinity of the competing employer that does not offer free food.
  • discourages outside friends and having a family

https://marker.medium.com/every-day-companies-around-the-world-execute-a-low-risk-high-return-arbitrage-they-buy-the-time-9be6e1c1d486