View apl1.md

#My APL page

My APL page at http://www.hakank.org/apl/ don't show correct APL characters on some browsers. Hopefully it works better at github. Note some hour later: Now that page seems to show the chars correct.

I tend to use Dyalog APL, and it's great dfns library (also used below).

##Some APL code Note: I'm not sure how well the special APL characters are shown in every browsers. There is an APL font (APL385.ttf) downloable from Dyalog which hopefully will give good result. Here is a direct link: Apl385.ttf

For the Project Euler problems, I have used some functions (e.g. fibonacci and factors) from the dfns library mentioned above; this may - or may not - be considering cheating.

View gist:946920
/
/ Here we explain a K function that shows all words in a word list
/ that are anagrams.
/
/
/ The K function used was found here:
/ http://lambda-the-ultimate.org/node/1323
/ Define the function
View gist:945167
/ Coupon collector's problem
/ E.g. how many times is required to throw a die
/ until all 6 values has been shown.
/
/ Or: How many coupons must be bought to get the the complete collection.
/
/ http://en.wikipedia.org/wiki/Coupon_collector%27s_problem
/ Let's simulate the die version.
View gist:944913
/ Here are some ways of solving the SEND+MORE=MONEY puzzle
/ in K (Kona).
/ See http://en.wikipedia.org/wiki/SEND_MORE_MONEY
/
/ The first version might not be the best K way, but this
/ declarative version is the on I'm used to from
/ constraint programming etc.
/ perm defined the permutations.
View gist:944856
/ This is a simulation of the "Birthday paradox"
/ (what I call "Birthday surprise")
/ See http://en.wikipedia.org/wiki/Birthday_problem
/ Take 20 samples of 0..364 with replacement
/ This represents the birthday of 20 persons.
20 ? 365
/ sample result
/ 195 361 24 274 145 108 157 259 51 228 330 88 180 228 86 197 121 182 336 133
View gist:944824
/ generate 10 random -1, 1 and
/ and count cumulative
+\ 10 ? (-1;1)
/ sample result
/ -1 0 1 0 1 2 1 2 1 2
/ just the last result:
+/x: 100 ? (-1;1)