w c l d _ _ u o y '
r s n t p k a e i h
_ f m g b j x , . _
w c l d _ _ y o u '
: legend | |
." Escape or Q to quit" cr | |
." Z to paint" cr | |
." L to load from a file" cr | |
." S to save to a file" cr | |
." P to see the text" cr | |
." R to enter the text" cr | |
." B to see in braille" cr | |
." Delete to clear" cr ; |
This was an exercise to take a peek at some different languages using a simple algorithm.
Average is an interesting algorithm to compare languanges. It is simple, but has enough complexity to demonstrate some differences between the languages.
Average requires calculating two different summary statistics (sum and count), then combining those two (division) into a single number. An efficient solution would only traverse the collection of numbers once.
Each of these are written as a function that would be given a collection of numbers. Whatever a collection means in that particular language. Some languages have multiple solutions that might have different tradeoffs.
Syntax | Name | Description | Example | Output | |
---|---|---|---|---|---|
+/x | Sum | Sum all value in x | +/1 2 3 4 5 | 15 | |
-':x | Deltas | Pairwise differences in x | -':1 2 3 4 | 1 1 1 1 | |
|+x | Rotate matrix | Rotate x counterclockwise | |+3 3#!9 | (2 5 8;1 4 7;0 3 6) | |
x@<x | Sort | Sort x | {x@<x}@8 3 7 1 | 1 3 7 8 | |
?x,y | Set union | Unique elements from x and y | ?"abac","adob" | "abcdo" | |
x^x^y | Intersection | Common elements from x and y | {?x^x^y}["abac";"adob"] | "aba" | |
x|-x | Absolute value | Absolute value of x | {x|-x}@-1 | 1 | |
*/y#x | Power | x in power of y (y>0) | {*/y#x}[2;5] | 32 | |
y@(#y)!x+!#y | Rotate left | Rotate y by x elements to the left | {y@(#y)!x+!#y}[3;"abcde"] | "deabc" |
;; This is based on a Dvorak keyboard layout and isn't | |
;; very comprehensive. The purpose is just to demonstrate | |
;; that you can create your own modal editing system in Emacs | |
;; using only a little bit of code. | |
;; | |
;; After loading this file, you can use "M-\" to enter command | |
;; mode (aka "normal-state"). | |
;; | |
;; To exit back to "insert-state", press "i". |
;;; echo-line.el --- Echo messages in minibuffer -*- lexical-binding:t -*- | |
;; | |
;; Author: Al Haji-Ali <[email protected]> | |
;; Version: 0.1.0 | |
;; Package-Requires: ((emacs "26.1")) | |
;; Keywords: message, echo, gui | |
;; | |
;; This file is not part of GNU Emacs. | |
;; | |
;; This program is free software; you can redistribute it and/or modify |
URL | Stars | Created |
---|---|---|
http://github.com/ahungry/ahungry-janet | 3 | 2020-05-29 02:54:07 |
http://github.com/ahungry/ahungry-janet-user | 0 | 2020-05-29 04:28:45 |
http://github.com/ahungry/janet-code | 8 | 2019-07-28 05:10:59 |
http://github.com/ahungry/janet-p99-map | 1 | 2020-05-10 04:13:27 |
http://github.com/ahungry/janet-pobox | 7 | 2020-05-27 04:36:08 |
http://github.com/ahungry/janet-xbuild | 2 | 2020-05-28 14:17:09 |
http://github.com/ahungry/puny-gui | 83 | 2020-04-24 02:52:59 |
http://github.com/ahungry/puny-server | 1 | 2020-04-23 01:42:38 |
Thought experiment:
Which k primitives can be implemented as k-strings, reasonably efficiently, with a handful of 'native' built-ins?
Not verified to be in dependency order yet... may depend on the choice of 'fundamental' primitives. Need to do speed tests too.
k9 syntax (download via Shakti). Got a better way to write one? Feel free to comment, you'll be credited!
# LVDB - LLOOGG Memory DB | |
# Copyriht (C) 2009 Salvatore Sanfilippo <[email protected]> | |
# All Rights Reserved | |
# TODO | |
# - cron with cleanup of timedout clients, automatic dump | |
# - the dump should use array startsearch to write it line by line | |
# and may just use gets to read element by element and load the whole state. | |
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands. | |
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump! |