Commit 4935ac62 by josd

### moving

parent 5c068153
 # EYE Imagining A collection of programs imagining linked data.
 === Bell function integral ===
 from sympy import * if __name__ == "__main__": x = Symbol('x') print('PREFIX : ') print('') print('"integrate(exp(-x**2), (x, -oo, oo))" :integrate-bell "%s".' % (integrate(exp(-x**2), (x, -oo, oo))))
 PREFIX : "integrate(exp(-x**2), (x, -oo, oo))" :integrate-bell "sqrt(pi)".
 #!/bin/bash python3 integrate-bell.py > integrate-bell.ttl
 === Easter Date ===
 from datetime import date def easter(year): "Returns Easter as a date object." "see http://code.activestate.com/recipes/576517-calculate-easter-western-given-a-year/" a = year % 19 b = year // 100 c = year % 100 d = (19 * a + b - b // 4 - ((b - (b + 8) // 25 + 1) // 3) + 15) % 30 e = (32 + 2 * (b % 4) + 2 * (c // 4) - d - (c % 4)) % 7 f = d + e - 7 * ((a + 11 * d + 22 * e) // 451) + 114 month = f // 31 day = f % 31 + 1 return date(year, month, day) if __name__ == "__main__": print('PREFIX xsd: ') print('PREFIX : ') print('') print('2019 :easter "%s"^^xsd:date.' % (easter(2019))) print('2020 :easter "%s"^^xsd:date.' % (easter(2020))) print('2021 :easter "%s"^^xsd:date.' % (easter(2021))) print('2022 :easter "%s"^^xsd:date.' % (easter(2022))) print('2023 :easter "%s"^^xsd:date.' % (easter(2023)))
 PREFIX xsd: PREFIX : 2019 :easter "2019-04-21"^^xsd:date. 2020 :easter "2020-04-12"^^xsd:date. 2021 :easter "2021-04-04"^^xsd:date. 2022 :easter "2022-04-17"^^xsd:date. 2023 :easter "2023-04-09"^^xsd:date.
 #!/bin/bash python3 easter.py > easter.ttl
 === Euler identity ===
 PREFIX : "E**(I*pi) + 1" :euler-identity 0 .
 #!/bin/bash python3 euler-identity.py > euler-identity.ttl
 === Fibonacci Numbers ===
 def fib(n, c={0:1, 1:1}): if n not in c: x = n // 2 c[n] = fib(x-1) * fib(n-x-1) + fib(x) * fib(n-x) return c[n] if __name__ == "__main__": print('PREFIX : ') print('') print('0 :fib %d .' % (fib(0))) print('91 :fib %d .' % (fib(91))) print('283 :fib %d .' % (fib(283)))
 PREFIX : 0 :fib 1 . 91 :fib 7540113804746346429 . 283 :fib 100694286476841731898333719576864360661213863366454327287613 .
 #!/bin/bash python3 fib.py > fib.ttl
 === Grover's algorithm ===
 PREFIX : "grover(7_bits, alternating_bits_oracle)" :grover (1 0 1 0 1 0 1).
 #!/bin/bash python3 grover.py > grover.ttl
 #!/bin/bash function imagining { echo "# \$(date)" > imagining.diff pushd bell; ./test.sh "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@' >> ../imagining.diff; popd pushd easter; ./test.sh "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@' >> ../imagining.diff; popd pushd euler; ./test.sh "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@' >> ../imagining.diff; popd pushd fib; ./test.sh "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@' >> ../imagining.diff; popd pushd grover; ./test.sh "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@' >> ../imagining.diff; popd } pushd ~/github.com/josd/eye/imagining imagining "\$@" popd
 # Mon Feb 18 00:32:42 CET 2019
 ---------------- Euler's identity ---------------- See https://en.wikipedia.org/wiki/Euler%27s_identity The tests are at http://josd.github.io/eye/reasoning/euler/test
 from sympy import * if __name__ == "__main__": print('PREFIX : ') print('PREFIX : ') print('') print('"E**(I*pi) + 1" :euler-identity %d .' % (E**(I*pi) + 1)) print(':main :euler-identity "E**(I*pi) + 1 = %d".' % (E**(I*pi) + 1))
 #Processed by EYE v19.0202.2255 josd #eye --nope --turtle - --pass PREFIX : :main :euler-identity "E**(I*pi) + 1 = 0". #2019-02-20T00:06:59.673Z in=1 out=1 ent=0 step=0 brake=1 inf=12451 sec=0.078 inf/sec=159628 #ENDS
 #!/bin/bash python3 euler-identity.py | eye --nope --turtle - --pass > euler-identity.ttl
 ------------------ Grover's algorithm ------------------ See https://en.wikipedia.org/wiki/Grover%27s_algorithm The tests are at http://josd.github.io/eye/reasoning/grover/test
 ... ... @@ -82,6 +82,6 @@ if __name__ == "__main__": # run Grover search to find a 7-bit solution lst = run_grover(eng, 7, alternating_bits_oracle) n3_lst = '(' + ' '.join([str(i) for i in lst]) + ')' print('PREFIX : ') print('PREFIX : ') print('') print('"grover(7_bits, alternating_bits_oracle)" :grover %s.' % (n3_lst)) print(':main :grover-algorithm "grover(7_bits, alternating_bits_oracle) = %s".' % (n3_lst))
 #Processed by EYE v19.0202.2255 josd #eye --nope --turtle - --pass PREFIX : :main :grover-algorithm "grover(7_bits, alternating_bits_oracle) = (1 0 1 0 1 0 1)". #2019-02-20T00:07:48.653Z in=1 out=1 ent=0 step=0 brake=1 inf=12481 sec=0.078 inf/sec=160013 #ENDS
 #!/bin/bash python3 grover.py | eye --nope --turtle - --pass > grover.ttl
 ... ... @@ -18,6 +18,7 @@ function reasoning { pushd easter; ./test "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@|#Processed by|#DONE|in=|#ENDS' >> ../reasoning.diff; popd pushd einstein; ./test "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@|#Processed by|#DONE|in=|#ENDS' >> ../reasoning.diff; popd pushd equation4; ./test "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@|#Processed by|#DONE|in=|#ENDS' >> ../reasoning.diff; popd pushd euler; ./test "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@|#Processed by|#DONE|in=|#ENDS' >> ../reasoning.diff; popd pushd fcm; ./test "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@|#Processed by|#DONE|in=|#ENDS' >> ../reasoning.diff; popd pushd fgcm; ./test "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@|#Processed by|#DONE|in=|#ENDS' >> ../reasoning.diff; popd pushd fib; ./test "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@|#Processed by|#DONE|in=|#ENDS' >> ../reasoning.diff; popd ... ... @@ -25,6 +26,7 @@ function reasoning { pushd glass; ./test "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@|#Processed by|#DONE|in=|#ENDS' >> ../reasoning.diff; popd pushd gps; ./test "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@|#Processed by|#DONE|in=|#ENDS' >> ../reasoning.diff; popd pushd graph; ./test "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@|#Processed by|#DONE|in=|#ENDS' >> ../reasoning.diff; popd pushd grover; ./test "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@|#Processed by|#DONE|in=|#ENDS' >> ../reasoning.diff; popd pushd h2o; ./test "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@|#Processed by|#DONE|in=|#ENDS' >> ../reasoning.diff; popd pushd hanoi; ./test "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@|#Processed by|#DONE|in=|#ENDS' >> ../reasoning.diff; popd pushd image; ./test "\$@"; git diff -U0 . | grep -E -v '^diff|^index|^Binary|^--|^\+-|\+\+|^@@|#Processed by|#DONE|in=|#ENDS' >> ../reasoning.diff; popd ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!