dawranliou / dawranliou.com Goto Github PK
View Code? Open in Web Editor NEWMy personal website
Home Page: https://dawranliou.com
My personal website
Home Page: https://dawranliou.com
(custom-set-variables
'(eglot-connect-timeout 300))
;; Fix for the clojure monorepo setup. We want to start the clojure-lsp under
;; the sub-directory instead of the project root (vc root).
(defun project-try-clojure-project (dir)
"Try to locate a Clojure project."
(when-let ((found (clojure-project-dir)))
(cons 'transient found)))
(defun find-clojure-project-advice (orig-fun &rest args)
"Fix project-root for the clojure monorepo setup."
(let ((project-find-functions
(cons #'project-try-clojure-project project-find-functions)))
(apply orig-fun args)))
(advice-add 'eglot-ensure :around #'find-clojure-project-advice)
Today I saw the tweet:
Today I (re-)learned that in Clojure, that when I try to access an element in a sequence with
get
, it returnsnil
.
Essentially, the provided code snippet evaluates to to nil
:
(get (map inc [1 2 3]) 0) ; => nil
Although lists (or Seqs) aren't supposed to be used as an Associative
, this behavior is quite interesting so I want to understand the Clojure RT more.
Here's the relevant RT code:
static public Object get(Object coll, Object key){
if(coll instanceof ILookup)
return ((ILookup) coll).valAt(key);
return getFrom(coll, key);
}
static Object getFrom(Object coll, Object key){
if(coll == null)
return null;
else if(coll instanceof Map) {
Map m = (Map) coll;
return m.get(key);
}
else if(coll instanceof IPersistentSet) {
IPersistentSet set = (IPersistentSet) coll;
return set.get(key);
}
else if(key instanceof Number && (coll instanceof String || coll.getClass().isArray())) {
int n = ((Number) key).intValue();
if(n >= 0 && n < count(coll))
return nth(coll, n);
return null;
}
else if(coll instanceof ITransientSet) {
ITransientSet set = (ITransientSet) coll;
return set.get(key);
}
return null;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.