Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------- | |
// | |
// Hypothesis: | |
// | |
// Promises/A is a Monad | |
// | |
// To be a Monad, it must provide at least: | |
// - A unit (aka return or mreturn) operation that creates a corresponding | |
// monadic value from a non-monadic value. | |
// - A bind operation that applies a function to a monadic value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** | |
* This gist provides a __FILE__ variable, which holds the path to the file | |
* from which the currently running source is being executed. | |
* | |
* Usage example: alert(__FILE__); | |
* | |
* Thanks to http://ejohn.org/blog/__file__-in-javascript/ on which this gist | |
* is based on. | |
* | |
* Tested in Mozilla Firefox 9, Mozilla Firefox 16, Opera 12, Chromium 18 |
See this Nim Forum Topic where this started.
Well I have a working Aporia version on my Yosemite OS X 10.10.2 from the new-suggest
branch of the repository.
BUT the lengths I had to go to get this working are plastered with stuff I did not understand :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a class that attempts to stop you accessing variables outside a lock. | |
// | |
// It does not do a perfect job, but can catch some common kinds of mistake, in | |
// particular when you accidentally try to work with objects inside closures that | |
// end up running later, outside the locked region (or in a different thread). | |
// EXAMPLE | |
val bank = ThreadBox(object { | |
val accounts by arrayListOf(10, 0, 0, 0).guard() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass, fields as datafields | |
from ujson import dumps, loads | |
# Note: ujson seamlessly serializes dataclasses, unlike stdlib's json | |
@dataclass | |
class Point: | |
x: float | |
y: float | |
# Shallow dataclass can be rebuilt from dict/json: |
Option<T> |
non-Option (T | undefined ) |
|
---|---|---|
accessing property | userOption.map(user => user.age) |
userNullish?.age |
calling a method | userOption.map(user => user.fn()) |
userNullish?.fn() |
providing fallback | ageOption.getOrElse(0) |
ageNullish ?? 0 |
filter | ageOption.filter(checkIsOddNumber) |
`ageNull |
Node Version Manager (https://github.com/nvm-sh/nvm) works perfectly across native node installations as well as emulated Rosetta installations. The trick I am using here is to install one LTS version of node under Rosetta and another stable version as native binary.
- find a way how to run the same node version on both platforms
OlderNewer