\t:100000 `freq@!s#>(s/!s*#v)!,/v%\.5+!s
941
\t:100000 `freq(s/!s*#v)s#>,/v%\.5+!s
9011,055 karma · joined July 21, 2017
\t:100000 `freq@!s#>(s/!s*#v)!,/v%\.5+!s
941
\t:100000 `freq(s/!s*#v)s#>,/v%\.5+!s
901[1] There's a handful of two-character primitives, as well as some special callable symbols (eg `freq @), but they don't come up nearly as often as the base set.
v: 10400 3400 6200
s: 15
quotients: ,/v%\.5+!s
labels: s/!s*#v / list of 15x 0, 1, 2. arbitrary; could instead be party names
top: s#>labels!quotients / k dicts can have duplicate keys; can sort items by key(^) or val(<>)
seats: `freq@!top / count appearances of dict's keys
The ability to transform a dict's values while keeping the labels (keys) unchanged - sort, arithmetic, etc - is really powerful.This answer is longer when minified, but it's faster in 2020.03.27:
\t:100000 +/s>(#v)^<>,/v%/.5+!s ⇒ 1494
\t:100000 `freq@!s#>(s/!s*#v)!,/v%\.5+!s ⇒ 691How to install: https://www.youtube.com/watch?v=l19Ef9v2uVI
Slides (view in Powerpoint slideshow mode to see the animated GIFs): https://github.com/chrispsn/presos/raw/master/2020-02-26%20M...
And past demo videos of the JS prototype:
- Basics: https://www.youtube.com/watch?v=_U6gE3cNgbI
- Dynamic tables: https://www.youtube.com/watch?v=x32tBLGrLAQ
Mesh's backend sits in one giant file because that's how we can write it in a Mesh sheet. But unfortunately the JS parsing library is huge and forms the bulk of the code. Happily, the k version is currently ~100 lines excluding tests.
If JSX were used, would the code need to be compiled? Mesh used to have a compilation step but it just added complexity (config files, build process, increased download size). Keep it simple! React.createElement is fine.
For example, in existing spreadsheet programs, each cell gets an A1-style location reference (even in an Excel table or a dynamic array).
That's not the case in Mesh, but it does something similar: a cell's default name is where it was entered in the grid UI, and (soon!) we update that name when the cell gets moved around.
ngn's; targets ngn/k (dude's a machine): https://bitbucket.org/ngn/k/src/master/aoc19/a.k
Mine; progressively porting from k7 to k9. Not as many answers and probably worse coding than ngn's, but perhaps more approachable for newcomers. https://github.com/chrispsn/aoc2019
llelf's; targets k7. Pretty slick. https://github.com/llelf/advent2019/blob/master/sol.k
k9 (Shakti) for a simpler product that's in the active language design phase and with not as much integrations - yet.
ngn/k for an actively developed version that's free and targets k6-era (for now).
Note this is k7 - dev has since moved to k9. k7 will be remembered as the 'Unicode symbols' experiment of k; for example nulls were slashed zeroes (Ø) and pi was, well, the pi symbol. k9 dropped them as they're not easy to type across all OSes without config or a dedicated editor.
k9 also has the nice dedicated 'cut' symbol, and a few other improvements, but it's not done yet.
Have you looked at q?
numpy has a lot of k/APLish primitives built in.
fml was also interesting but never made it past the spec stage:
https://www.reddit.com/r/apljk/comments/etpbbf/fml_an_optimi...
I like the choices of primitives in K and the novel ways they can be combined to do things more efficiently (and with fewer pieces!) than you may expect. Good examples are 'where' (&), the grade twins (< and >), scan (\), and eachprior (':).
I love the adverb syntax: each (') lets you map a function over a data structure with zero syntactic effort, and 'over' (/) and 'scan' (\) make reductions trivial.
With regards to an on-ramp, I started with John Earnest's oK REPL and did a bunch of Project Euler and Advent of Code problems. I then moved to trying to understand the examples on kparc.com. I then converted a spreadsheet application from JS to k7. In all of this, John's documentation was essential.
For me, having single variable names isn't paramount, but in some cases - particularly functions - I can see it helps to 'drive' your mind towards finding simpler ways to do things. It lets the characters that do the 'real' work come to the forefront.
https://github.com/indiscible/qmandel
And Arthur's version in k (also below):
I should convert it to k9 (Shakti)...
+/~^+/b*b:49{c+(-/x*x;2**/x)}/c:-1.5 -1+(2*!2#w)%w:10https://gist.github.com/chrispsn/da00835bb122c42f429a084df83...
design goal: speed
write fast, run fast, modify fast.
minimize product of vocabulary and program size.
https://a.kx.com/a/k/readme.txt comprehensive programming environments
(programming, files, comms, procs, ...)
are depressingly complex.
commonlisp, c/lib/syscalls, java, winapi
are all in the 1000's of entry points.
many with multiple complex parameters.
with k we try to do more with less
in order to write correct programs faster.
https://web.archive.org/web/20041024065350/http://www.kx.com... > Just curious, but does the state of California charge you a large tax
> for each character in a variable name?
yes.
we also try to fit our algorithms onto licence plates.
https://web.archive.org/web/20040823040634/http://www.kx.com...For some 'licence plate' K algorithm dissections, you might like this Twitter account:
What would you do?
https://twitter.com/jckarter/status/1221232990233038848?s=20