GithubHelp home page GithubHelp logo

let-alist's Introduction

About

This Common Lisp package provides macros let-alist and let-dolist-alist that simplify access to (even buried) assoc lists.

The let-alist macro is modeled by Emacs lisp macro of same name. The rest of this section quotes Emacs documentation:

Creates a binding for each symbol used as keys the association list ALIST, prefixed with dot. This can be useful when accessing several items in the same association list, and it’s best understood through a simple example:

(let-alist '((:rose . red) (:lily . white) (:buttercup . yellow))
  (if (eq .rose 'red)
      .lily))
⇒ white

The BODY is inspected at compilation time, and only the symbols that appear in BODY with a ‘.’ as the first character in the symbol name will be bound. Finding the keys is done with ‘assoc’, and the ‘cdr’ of the return value of this ‘assoc’ is assigned as the value for the binding.

Nested association lists is supported:

(let-alist '((:rose . red) (:lily (:belladonna . yellow) (:brindisi . pink)))
  (if (eq .rose 'red)
      .lily.belladonna))
⇒ yellow

Nesting ‘let-alist’ inside each other is allowed, but the code in the inner ‘let-alist’ can’t access the variables bound by the outer ‘let-alist’.

Differencies from Emacs version

  • The primary package used is KEYWORD - it means that .foo symbol (variable name) looks for :foo keyword in the alist (actually, this is what parsing from json and/or xml often ends up with)

Exported symbols

License

This is modified (translated from emacs lisp to Common Lisp) let-alist.el file from GNU Emacs. As such, it is (and needs to be) under GNU GPL.

let-alist's People

Contributors

zellerin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.