Mostrando entradas con la etiqueta common lisp. Mostrar todas las entradas
Mostrando entradas con la etiqueta common lisp. Mostrar todas las entradas

domingo, 15 de noviembre de 2020

Programming with Constraints

I've been following https://www.hillelwayne.com/ for some time and there's always something valuable to take to your daily life from each one of his posts.

Highest level is queuing theory and TLA+ stuff. But the couple of articles that touched home the most are his J lang article and the decision table patterns (and its intro from long time ago). 

He uses productivity tools that reasonate a lot with my way of tooling. AutoHotKey, editors, minilanguages and, Constraint Propagation Systems.

On CPS, he talks about MiniZinc and OR-Tools. For me, Oz/Mozart rang a bell (from CPM book), and cl:screamer. I don't know if Z3 overlaps with it, but worth mentioning too.

Now onto my usage/takeaway of this: I used screamer to create a magic-square some time ago, and last week I was thinking if I could use screamer, Prolog, or PiLog to solve the coin change problem.

Well, as just today, I read about this MiniZinc tool and when this watching the MiniZinc videos, it was clear that yes, it should be possible, and it might be worth to try the coin change there. Here's what I came with (using screamer):



I haven't figured out how to do the performance analysis of this, but I suspect it will be less efficient than the usual manual way, because the only 'fitness' function is v=, but it's a complete hit-or-miss. once the current factors add up to an already bigger num than out target, this algorithm will keep trying "what if I add one coin of 1cent?", "and what about 2?".  

IIRC, in CPM, there are some explanations of smarter CPS, but I'm not sure if they apply here, as there is only a single 'cut', which is the final objective function.

miércoles, 15 de marzo de 2017

Browsing allegro lisp docs inside emacs

While programming, I love to read documentation using helm-dash. I've created quite a few docsets for apps/languages that lacked them in the official repos.

Currently I was using python, common lisp, Picolisp, and Redis, but I felt I was going too often to the franz's Allegro Lisp documentation site.  It's nice and loads fast, but it doesn't provide any useful search.

So I created a dash docset for Franz's Allegro Lisp.  As usual, it's in my github.

And here's a little gif I recorded to see how does it look.


miércoles, 8 de febrero de 2017

Henry G Baker's papers

I was rereading "Out of the tarpit" paper, and by the end of it I noticed they reference a paper from Henry Baker: "Equal rights for functional objects or, the more things change, the more they are the same.". The author's name rang a bell, and I decided to explore a bit more.

So, He's the author of a paper I loved to read 3 months ago or so: Pragmatic Parsing in Common Lisp.

The article is an adaptation of Val Schorre's META-II paper to common lisp, leveraging reader macros to create parsers in very few lines of code.

Reading a bit more, I found this other very enjoyable article: Metacircular Semantics for Common Lisp Special Forms . This one takes the approach of metacircular interpreters to explain the behaviour of some common lisp special forms in terms of other common lisp expressions.  I love the bottom up approach, and reminds me of "git from the bottom up", or CTMCP's explanations of the extensions to the Oz language.

He wrote lots of articles related to Lisp to different degrees, but most of them (the ones I skimmed) are written in a very clear language (no pun intended), and quite fun and enlightening reads.

martes, 30 de agosto de 2016

slime inspect + eval

When inspecting some value in slime-inspector, you may want to evaluate forms on that value.

That's what 'e' `slime-inspector-eval' is for.  What the docs do not put very clear is that '*' is the variable bound to the value.


lunes, 18 de julio de 2016

TIL: Remove a defined method (with defmethod) in Common Lisp

I created a defmethod for a more specialized class than the ones existed. and now I'd like to remove that method....

(remove-method #'foo (find-method #'foo '() (mapcar #'find-class '(class-of-first-specializer class-of-second-specializer))))