941 karma · joined February 14, 2009
I also quit social media and told no one (oops, it seems I just did).
12_345_678
1.2345678e7http://www.rae.es/consultas/tilde-en-las-mayusculas (link in Spanish).
Personally (I'm a nobody that doesn't always agree with the Academy) I don't like omitting the accents at all in any circumstances.
(header :: rows).mkString("", "\n", "\n")
My two cents: I prefer the second solution. Maybe it's because I have never programmed in Java. # vim: set fileencoding=iso-8859-1
Trivia bit: the Python interpreter understands Vim and Emacs modelines as encoding declaration for source files: https://www.python.org/dev/peps/pep-0263/#defining-the-encod...Another use case was specifying the indentation scheme for the file for weird conventions like "2 space indentation with 4-column tabs" (first level is two spaces, second level is one tab, third level is one tab plus two spaces...)
Fortunately now everything's UTF-8 and weird indentation schemes are uncommon.
f 0 = doThing
f 1 = otherThing
f _ = doDefault $ python2
>>> def f((a, b)):
... return a + b
...·
>>> f((1, 2))
3
$ python3
>>> def f((a, b)):
File "<stdin>", line 1
def f((a, b)):
^
SyntaxError: invalid syntaxFrom the very little APL I've learnt, I know that operators always have either one parameter (named ω) or two (named α and ω), and their inputs and outputs are always arrays.
If you need to write a lot of such functions, it makes sense to define some macros to help you:
#define V1(f) A f(w)A w; // create one-arg function
#define V2(f) A f(a,w)A a,w; // create two-arg function
#define DO(n,x) {I i=0,_n=(n);for(;i<_n;++i){x;}}
iota is the APL equivalent of Python's range function: V1(iota) { // Define one-arg function iota.
I n = *w->p; // Get the value of the ω argument.
A z = ga(0, 1, &n); // Allocate output array.
DO(n, z->p[i] = i); // Assign increasing integers.
R z; // Return the result.
}
The plus function adds two arrays: V2(plus) { // Define two-arg function plus.
I r = w->r, // Get the rank of ω.
*d = w->d, // Get a pointer to ω's data.
n = tr(r,d); // Get tne size of ω's data.
A z = ga(0, r, d); // Allocate output array.
DO(n, z->p[i] = a->p[i] + w->p[i]);
// Add corresponding values of α and ω
R z; // Return the result.
}
Personally I cannot tolerate the lack of whitespace, but the APL guys are known to like to see their entire programs in one screenful. I can understand that some people like to write code like this.I like this one: https://fsharpforfunandprofit.com/posts/designing-for-correc...
But is not a deal breaker for me. If the language doesn't let me I can use `ii` or `i2` or whatever.
Greek letters are always a latin letter followed by an asterisk. Arrows and comparison operators are what one would guess. Mathematical symbols generally make some sense:
<C-k> a * α
<C-k> F * Φ
<C-k> = > ⇒
<C-k> - > →
<C-k> > = ≥
<C-k> 0 0 ∞
<C-k> d P ∂
<C-k> I n ∫
[1]: https://tools.ietf.org/html/rfc1345For example, here I'm building cons, car and cdr just to create a list, from which I'll get its second value:
(cons => car => cdr =>
// this block is my little world where I have lists
car(cdr(cons(1)(cons(2)(cons(3)(4)))))
)( // cons
carValue => cdrValue => extractor => extractor(carValue)(cdrValue)
)( // car
consValue => (consValue)(x => y => x)
)( // cdr
consValue => (consValue)(x => y => y)
)
(This is JavaScript-looking lambda calculus, so you can evaluate it in your browser's developer console).