Giter Site home page Giter Site logo

cl-hash-literal's Introduction

cl-hash-literal

Synopsis

Use hash-table literal read table.

$ ros install dice-k-nakatani/cl-hash-literal # or load with asdf or quicklisp.
$ ros run                                     # or launch repl with sbcl, ccl64 etc.
(require :cl-hash-literal)
(cl-syntax:use-syntax :cl-hash-literal)
;; change syntax-table
(let ((tab #1h(:a 10 :b 20))) (gethash :b tab))
;; => 20, t

Print object with hash-table literal read.

(use-package :cl-hash-literal)
;; import with-hash-literal-printer

(with-hash-literal-printer
    (prin1-to-string 
      (let ((tab (make-hash-table :test #'eql)))
        (setf (gethash :a tab) 10
              (gethash :b tab)  20)
        tab)))
;; => "#1h(:A 10 :B 20 )"

Description

Sometimes we need hash-table literal. plist is not enough. alist is redundant to write and not enough yet.

cl-hash-literal provides:

  1. hash-table literal syntax #h(:a 1 :b 2).

  2. macro to print-object with hash-table literal syntax.

The #h syntax is the same as the cl21's one.

But with cl-hash-literal, you can specify the test function (in other words, looseness level on equality) with numarg.

#1h(:a 1 :b 2) is a hash-table with eql test function.

Here is the list of numarg.

0 : eq
1 : eql
2 : equal
3 : equalp
otherwise : equal

Author

Copyright

Copyright (c) 2019 dn ([email protected])

License

Licensed under the MIT License.

cl-hash-literal's People

Contributors

dice-k-nakatani avatar

Watchers

James Cloos 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.