This file contains hidden or 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
my constant @fib = 1, 1, *+* ... *; |
This file contains hidden or 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
#You can also copy/paste this directly into the command line if perl6 is installed | |
perl6 -e "say π - 4 * ([+] (( 1 <</<< (1,5,9...5000) ) Z ( -1 <</<< (3,7...5000))).flat)" | |
# This is an implementation of the Madhava-Lebniz series: https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80 | |
# This script creates two series (1,5...) and (3,7) for even and odd positions in the sequence. | |
# Then, the inverse of the sequence is computed 1/(the sequence) with the 1<</<< construction | |
# Then they are zipped together using Z | |
# Finally, [+] sums all terms of the sequence together. Since the sequence is an approximation to π/4 it's multiplied by 4 | |
# and then substracted from π. This should give a good 3-digit approximation. Change 5000 by a bigger number if you want bigger precision |
This file contains hidden or 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
#You can also copy/paste this directly into the command line if perl6 is installed | |
raku -e "say π - 4 * ([+] <1 -1> <</<< (1,3,5,7,9...10000)) " | |
# This is an implementation of the Madhava-Lebniz series: https://en.wikipedia.org/wiki/Leibniz_formula_for_%CF%80 | |
# And a better, or at least shorter, version of https://gist.github.com/JJ/23801c82b218b25da7fc8831b7c331ad | |
# Instead of creating two series and combining them, this combines 1,-1 and the series of odd numbers | |
# by applying them successively: 1 divided by the first, -1 by the second, and so on. This creates exactly the same effect. | |
# It is faster and you only need to change one number, the 10000, to compute Pi with a bigger precision. |
This file contains hidden or 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 cypher applies character displacement to a set of letters using a "cypher" both users must have | |
perl6 -e "say (<1 -1 3 -3 4> <<+<< <t h i s i s s o s 1 k r i t>.map: {.ord}).map: {.chr}" | |
# In this case, the cypher is <1 -1 3 -3 4> and will be applied to the message after <<+<< | |
# You can retrieve the original message by applying the inverse of the cypher | |
perl6 -e "say (<-1 1 -3 3 -4> <<+<< <u g l p m t r r p 5 l q l q>.map: {.ord}).map: {.chr}" |
This file contains hidden or 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
# The first argument will be n and entered into the $^ß placeholder, the second into the $^þ placeholder | |
perl6 -e 'say { ([*] 1..$^ß ) / ( [*] 1..$^þ) * ([*] 1..($^ß - $^þ)) }(@*ARGS[0],@*ARGS[1])' 20 11 | |
# [*] 1..$^ß ) will compute the factorial by creating a range 1..$^ß and then multiplying all of them together. | |
# @*ARGS contains the arguments handled to the script; @*ARGS[0] will be the first and so on. |
This file contains hidden or 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
.PHONY: clean | |
BKDIR = /tmp/copia | |
$(BKDIR): . | |
rsync -avz $< $@ | |
clean: | |
rm *~ |
This file contains hidden or 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
.PHONY: clean | |
recipes.zip: . | |
zip recipes.zip *.mk *.md | |
clean: | |
rm *~ |
This file contains hidden or 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
.PHONY: spellcheck | |
spellcheck: | |
hunspell -p words.dic -l *.md | grep . && exit 2 || exit 0 |
This file contains hidden or 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
.PHONY = commit | |
status: | |
-git status -s | grep . && touch status | |
commit: status | |
rm status; make -f 3.mk | |
git commit -am "$(msg)" |
This file contains hidden or 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
%.pdf: %.tex | |
pdflatex $< | |
bibtex $(basename $<) | |
pdflatex $< | |
pdflatex $< |