GithubHelp home page GithubHelp logo

dawranliou / dawranliou.com Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 2.0 42.56 MB

My personal website

Home Page: https://dawranliou.com

HTML 16.11% Shell 0.40% Clojure 37.32% CSS 11.20% Emacs Lisp 0.50% JavaScript 34.46%

dawranliou.com's People

Contributors

dawranliou avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

dawranliou.com's Issues

Advise `eglot` to support Clojure monorepo setup

(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)

Add article on clojure.core/get

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 returns nil.

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;
}

Small Bug: Wrong links

Hey, Daw-Ran, I stumbled upon your website today and noticed that you have these two links swapped. Must have been an oversight. Just wanted to give you a heads-up.

image

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.