diff options
Diffstat (limited to '080_blog/00040_Haskell-Projects')
12 files changed, 0 insertions, 875 deletions
diff --git a/080_blog/00040_Haskell-Projects/00040_Graham-Scan/index.md b/080_blog/00040_Haskell-Projects/00040_Graham-Scan/index.md deleted file mode 100644 index 195dbe1..0000000 --- a/080_blog/00040_Haskell-Projects/00040_Graham-Scan/index.md +++ /dev/null @@ -1,128 +0,0 @@ -Haskell – Convex Hull – Graham Scan -=================================== - -December 16, 2017 - -Playing with Convex Hulls (via Graham Scan) and SVG Export in Haskell: - -This is an embedded SVG generated by the Haskell programm below: - -<svg style="background-color:black;border:3px solid green;margin:2px;" width="330" height="330"><circle cx="250.04284841107818" cy="201.75346959836142" r="5" fill="rgb(30,150,112)"></circle> <circle cx="168.06592772450588" cy="111.843758303498" r="5" fill="rgb(30,150,47)"></circle> <circle cx="189.1691117845287" cy="250.13932743386943" r="5" fill="rgb(30,150,107)"></circle> <circle cx="130.9047490592456" cy="253.98605115515113" r="5" fill="rgb(30,150,108)"></circle> <circle cx="133.43531697969132" cy="255.82160214659208" r="5" fill="rgb(30,150,109)"></circle> <circle cx="182.304020607504" cy="105.5457583516454" r="5" fill="rgb(30,150,60)"></circle> <circle cx="251.5850563588106" cy="65.40572671380644" r="5" fill="rgb(30,150,139)"></circle> <circle cx="171.80987991027797" cy="186.35194010383304" r="5" fill="rgb(30,150,37)"></circle> <circle cx="207.80255687618114" cy="132.29096928312123" r="5" fill="rgb(30,150,61)"></circle> <circle cx="195.49409554478555" cy="83.18625335312012" r="5" fill="rgb(30,150,87)"></circle> <circle cx="92.72787404887227" cy="119.1126315578156" r="5" fill="rgb(30,150,76)"></circle> <circle cx="132.01826662198954" cy="259.3032349925243" r="5" fill="rgb(30,150,113)"></circle> <circle cx="254.30961953454" cy="228.57029782885428" r="5" fill="rgb(30,150,131)"></circle> <circle cx="119.4923496517701" cy="224.99714968272923" r="5" fill="rgb(30,150,83)"></circle> <circle cx="104.9029796235115" cy="248.66327951701538" r="5" fill="rgb(30,150,112)"></circle> <circle cx="177.91310266020778" cy="126.62370162491455" r="5" fill="rgb(30,150,38)"></circle> <circle cx="266.34722960770284" cy="187.10030895652505" r="5" fill="rgb(30,150,123)"></circle> <circle cx="198.64979304554535" cy="188.53978156044514" r="5" fill="rgb(30,150,58)"></circle> <circle cx="153.9541873486683" cy="57.38878027501561" r="5" fill="rgb(30,150,103)"></circle> <circle cx="170.63539358861877" cy="176.00651132793615" r="5" fill="rgb(30,150,27)"></circle> <circle cx="28.36356558991553" cy="95.4663889254756" r="5" fill="rgb(30,150,148)"></circle> <circle cx="144.84264545840333" cy="98.7746298856041" r="5" fill="rgb(30,150,60)"></circle> <circle cx="190.22210041855752" cy="135.09803947887505" r="5" fill="rgb(30,150,42)"></circle> <circle cx="182.77513675509647" cy="226.9525049033775" r="5" fill="rgb(30,150,81)"></circle> <circle cx="91.5545715639725" cy="181.77301165017755" r="5" fill="rgb(30,150,73)"></circle> <circle cx="260.52976404909987" cy="126.7650903973776" r="5" fill="rgb(30,150,116)"></circle> <circle cx="199.24706728106065" cy="85.8145677264196" r="5" fill="rgb(30,150,87)"></circle> <circle cx="140.1028394863066" cy="228.94903207761297" r="5" fill="rgb(30,150,80)"></circle> <circle cx="86.45512221013155" cy="142.21354112994936" r="5" fill="rgb(30,150,74)"></circle> <circle cx="104.7684570753781" cy="95.55777241192189" r="5" fill="rgb(30,150,82)"></circle> <circle cx="109.8116912935771" cy="201.82250066393837" r="5" fill="rgb(30,150,69)"></circle> <circle cx="226.2427629753817" cy="260.4928511647599" r="5" fill="rgb(30,150,135)"></circle> <circle cx="207.52854584882476" cy="98.23832427848856" r="5" fill="rgb(30,150,82)"></circle> <circle cx="137.34727138289463" cy="248.54598831387364" r="5" fill="rgb(30,150,101)"></circle> <circle cx="67.6437518548912" cy="235.9987917257608" r="5" fill="rgb(30,150,126)"></circle> <circle cx="146.63935287123562" cy="199.14394352970618" r="5" fill="rgb(30,150,47)"></circle> <circle cx="166.09256427911302" cy="242.83302095042907" r="5" fill="rgb(30,150,94)"></circle> <circle cx="184.35531117256224" cy="161.9097796435418" r="5" fill="rgb(30,150,32)"></circle> <circle cx="135.0509917491549" cy="104.7711158701602" r="5" fill="rgb(30,150,57)"></circle> <circle cx="219.20921008912157" cy="115.18635102633722" r="5" fill="rgb(30,150,80)"></circle> <circle cx="163.3590840337916" cy="68.94091343798308" r="5" fill="rgb(30,150,91)"></circle> <circle cx="106.80531573718335" cy="199.21285711361014" r="5" fill="rgb(30,150,69)"></circle> <circle cx="91.69394054319545" cy="249.00283065566003" r="5" fill="rgb(30,150,120)"></circle> <circle cx="42.69884845673566" cy="208.11969850342197" r="5" fill="rgb(30,150,131)"></circle> <circle cx="150.6236743485051" cy="188.8620474963915" r="5" fill="rgb(30,150,36)"></circle> <circle cx="158.90382633613356" cy="274.07594874616575" r="5" fill="rgb(30,150,126)"></circle> <circle cx="203.43810936607744" cy="240.5130006472947" r="5" fill="rgb(30,150,104)"></circle> <circle cx="90.52909317079552" cy="217.88023089739372" r="5" fill="rgb(30,150,95)"></circle> <circle cx="142.0940864941062" cy="129.52923503909" r="5" fill="rgb(30,150,30)"></circle> <circle cx="183.3037554100898" cy="163.4224683254946" r="5" fill="rgb(30,150,31)"></circle> <circle cx="254.59761377280722" cy="194.8355635900217" r="5" fill="rgb(30,150,113)"></circle> <circle cx="70.01341642229187" cy="145.07162677904222" r="5" fill="rgb(30,150,90)"></circle> <circle cx="245.95274031933198" cy="105.6150023686217" r="5" fill="rgb(30,150,109)"></circle> <circle cx="179.3874489883276" cy="161.3271491454406" r="5" fill="rgb(30,150,26)"></circle> <circle cx="174.8322909478738" cy="98.24413130742855" r="5" fill="rgb(30,150,63)"></circle> <circle cx="76.57661314940059" cy="232.5620695235213" r="5" fill="rgb(30,150,117)"></circle> <circle cx="110.20050744456465" cy="131.53437983901722" r="5" fill="rgb(30,150,53)"></circle> <circle cx="101.02068320616426" cy="147.86628733061426" r="5" fill="rgb(30,150,57)"></circle> <circle cx="165.8572064460344" cy="278.14694842092365" r="5" fill="rgb(30,150,131)"></circle> <circle cx="100.51994290684408" cy="135.00585528086626" r="5" fill="rgb(30,150,61)"></circle> <circle cx="93.82764097353034" cy="129.06320594160917" r="5" fill="rgb(30,150,70)"></circle> <circle cx="253.87187416210415" cy="154.5167254215345" r="5" fill="rgb(30,150,105)"></circle> <circle cx="139.60104049751217" cy="105.10237893042421" r="5" fill="rgb(30,150,55)"></circle> <circle cx="217.63333767494922" cy="82.01911898999408" r="5" fill="rgb(30,150,102)"></circle> <circle cx="155.07651713848244" cy="202.01229698806958" r="5" fill="rgb(30,150,49)"></circle> <circle cx="38.84571396023169" cy="211.71370049299298" r="5" fill="rgb(30,150,137)"></circle> <circle cx="131.35457460373755" cy="229.43649756282707" r="5" fill="rgb(30,150,82)"></circle> <circle cx="101.8811149603446" cy="60.806865650812135" r="5" fill="rgb(30,150,114)"></circle> <circle cx="108.91357375361146" cy="183.38328826229434" r="5" fill="rgb(30,150,57)"></circle> <circle cx="98.29711330271346" cy="109.47482179229984" r="5" fill="rgb(30,150,77)"></circle> <circle cx="172.28688779196867" cy="181.46233752550535" r="5" fill="rgb(30,150,33)"></circle> <circle cx="93.77188129034651" cy="152.09728921642983" r="5" fill="rgb(30,150,65)"></circle> <circle cx="39.16221208499168" cy="220.08715706943792" r="5" fill="rgb(30,150,141)"></circle> <circle cx="82.90283027529738" cy="187.23987823799342" r="5" fill="rgb(30,150,83)"></circle> <circle cx="36.83140136457256" cy="237.10836498299798" r="5" fill="rgb(30,150,152)"></circle> <circle cx="159.04913429058357" cy="193.6137496983329" r="5" fill="rgb(30,150,41)"></circle> <circle cx="149.8458394746179" cy="243.69722670699878" r="5" fill="rgb(30,150,94)"></circle> <circle cx="139.0710264338086" cy="147.9219518871481" r="5" fill="rgb(30,150,18)"></circle> <circle cx="156.87676351678834" cy="196.31621769543472" r="5" fill="rgb(30,150,43)"></circle> <circle cx="76.22813867551673" cy="58.065254250002404" r="5" fill="rgb(30,150,132)"></circle> <circle cx="114.74404579519961" cy="250.4087840946835" r="5" fill="rgb(30,150,110)"></circle> <circle cx="87.15900106326063" cy="148.70527298969148" r="5" fill="rgb(30,150,72)"></circle> <circle cx="26.847893428897535" cy="218.50461482065617" r="5" fill="rgb(30,150,151)"></circle> <circle cx="167.86224317149043" cy="217.21693364547622" r="5" fill="rgb(30,150,67)"></circle> <circle cx="282.75471021838604" cy="222.40422121056434" r="5" fill="rgb(30,150,153)"></circle> <circle cx="113.65929983185622" cy="172.1380647926459" r="5" fill="rgb(30,150,47)"></circle> <circle cx="145.09413645816042" cy="155.25057732001034" r="5" fill="rgb(30,150,10)"></circle> <circle cx="237.53341559112823" cy="129.6627629148239" r="5" fill="rgb(30,150,91)"></circle> <circle cx="204.79599735549814" cy="127.38370156552024" r="5" fill="rgb(30,150,60)"></circle> <circle cx="67.74775493976351" cy="139.97850753416574" r="5" fill="rgb(30,150,94)"></circle> <circle cx="210.31226434244496" cy="247.09502723685614" r="5" fill="rgb(30,150,114)"></circle> <circle cx="138.5101000851674" cy="278.7105427190394" r="5" fill="rgb(30,150,132)"></circle> <circle cx="169.19801602950238" cy="114.05245580753565" r="5" fill="rgb(30,150,46)"></circle> <circle cx="248.30023598811576" cy="139.82948336104496" r="5" fill="rgb(30,150,100)"></circle> <circle cx="84.30932668117279" cy="219.93833030785126" r="5" fill="rgb(30,150,101)"></circle> <circle cx="132.24331417077946" cy="291.2609993001805" r="5" fill="rgb(30,150,146)"></circle> <circle cx="160.94658587409114" cy="77.98657154244181" r="5" fill="rgb(30,150,82)"></circle> <circle cx="189.89599533144758" cy="214.5141658021252" r="5" fill="rgb(30,150,73)"></circle> <circle cx="274.07238032907736" cy="114.61040292334776" r="5" fill="rgb(30,150,133)"></circle> <circle cx="173.4334175877005" cy="142.41875279561097" r="5" fill="rgb(30,150,23)"></circle> <circle cx="81.59666952240286" cy="157.09683628233245" r="5" fill="rgb(30,150,78)"></circle> <circle cx="113.74263460749069" cy="245.6984634962466" r="5" fill="rgb(30,150,105)"></circle> <circle cx="128.62844736870682" cy="89.1045872570648" r="5" fill="rgb(30,150,75)"></circle> <circle cx="117.09080103183433" cy="256.3606817576775" r="5" fill="rgb(30,150,114)"></circle> <circle cx="107.0510464556047" cy="63.6364881544602" r="5" fill="rgb(30,150,109)"></circle> <circle cx="146.06063748335822" cy="155.5476601817892" r="5" fill="rgb(30,150,9)"></circle> <circle cx="19.797156728201166" cy="208.00327375672293" r="5" fill="rgb(30,150,154)"></circle> <circle cx="224.6871261564196" cy="59.32941538253692" r="5" fill="rgb(30,150,125)"></circle> <circle cx="18.330634507062157" cy="169.68512490920642" r="5" fill="rgb(30,150,146)"></circle> <circle cx="117.71877593737015" cy="157.71566996945785" r="5" fill="rgb(30,150,39)"></circle> <circle cx="150.90744004872494" cy="125.69996651911103" r="5" fill="rgb(30,150,31)"></circle> <circle cx="172.0555296451493" cy="147.95967101995438" r="5" fill="rgb(30,150,19)"></circle> <circle cx="211.71510600782037" cy="168.6836805807738" r="5" fill="rgb(30,150,61)"></circle> <circle cx="60.24756518573737" cy="246.71025625213787" r="5" fill="rgb(30,150,140)"></circle> <circle cx="103.23366497661333" cy="219.01237316076927" r="5" fill="rgb(30,150,87)"></circle> <circle cx="273.7017283881007" cy="172.2120764305319" r="5" fill="rgb(30,150,127)"></circle> <circle cx="97.80303649638779" cy="204.85716575700624" r="5" fill="rgb(30,150,80)"></circle> <circle cx="221.46148887605563" cy="164.77249284618293" r="5" fill="rgb(30,150,71)"></circle> <circle cx="50.524491137739275" cy="89.6937642622213" r="5" fill="rgb(30,150,130)"></circle> <circle cx="204.0380699117014" cy="37.35498291700646" r="5" fill="rgb(30,150,135)"></circle> <circle cx="143.40838746301495" cy="259.3899906185589" r="5" fill="rgb(30,150,111)"></circle> <circle cx="266.77265013944714" cy="123.56187324575204" r="5" fill="rgb(30,150,123)"></circle> <circle cx="121.09007007148857" cy="87.19247610877495" r="5" fill="rgb(30,150,80)"></circle> <circle cx="80.22930186274945" cy="70.1701303865456" r="5" fill="rgb(30,150,120)"></circle> <circle cx="180.45553719901778" cy="175.95293706048568" r="5" fill="rgb(30,150,35)"></circle> <circle cx="222.7506070445607" cy="80.61735797855984" r="5" fill="rgb(30,150,106)"></circle> <circle cx="158.2801305209321" cy="168.2844490594726" r="5" fill="rgb(30,150,14)"></circle> <circle cx="209.07427850176043" cy="146.00598552038022" r="5" fill="rgb(30,150,58)"></circle> <circle cx="181.8649175345449" cy="96.87537796898624" r="5" fill="rgb(30,150,68)"></circle> <circle cx="57.818033309206335" cy="94.70613646665379" r="5" fill="rgb(30,150,121)"></circle> <circle cx="120.75849455577627" cy="136.86343872502906" r="5" fill="rgb(30,150,41)"></circle> <circle cx="238.4042177525126" cy="214.12837089906836" r="5" fill="rgb(30,150,108)"></circle> <circle cx="134.82175169469224" cy="282.8625044224542" r="5" fill="rgb(30,150,137)"></circle> <circle cx="124.37897828966902" cy="141.19895073915285" r="5" fill="rgb(30,150,35)"></circle> <circle cx="71.30829640124736" cy="228.6244751809119" r="5" fill="rgb(30,150,118)"></circle> <circle cx="202.8966932024821" cy="175.5553271682116" r="5" fill="rgb(30,150,55)"></circle> <circle cx="112.28137080688083" cy="198.61669563281163" r="5" fill="rgb(30,150,64)"></circle> <circle cx="230.79728693422757" cy="72.90445718027976" r="5" fill="rgb(30,150,118)"></circle> <circle cx="158.79949910260785" cy="182.82233984968175" r="5" fill="rgb(30,150,29)"></circle> <circle cx="58.56877652829822" cy="147.81482668362486" r="5" fill="rgb(30,150,102)"></circle> <circle cx="188.43313680897649" cy="169.0946893542551" r="5" fill="rgb(30,150,38)"></circle> <circle cx="183.18362562517675" cy="146.11507672367435" r="5" fill="rgb(30,150,31)"></circle> <circle cx="256.71894488922624" cy="172.26799561066733" r="5" fill="rgb(30,150,109)"></circle> <circle cx="245.03698870042268" cy="103.65831068003733" r="5" fill="rgb(30,150,110)"></circle> <circle cx="50.70099080152846" cy="87.39565736040664" r="5" fill="rgb(30,150,132)"></circle> <circle cx="130.64433518067872" cy="28.1630727673696" r="5" fill="rgb(30,150,137)"></circle> <circle cx="94.56724747823085" cy="150.4574267806313" r="5" fill="rgb(30,150,64)"></circle> <circle cx="67.04524904809107" cy="53.02953597638252" r="5" fill="rgb(30,150,143)"></circle> <circle cx="78.62648151898244" cy="81.82623533931174" r="5" fill="rgb(30,150,112)"></circle> <circle cx="161.15153490662175" cy="96.99587052613042" r="5" fill="rgb(30,150,61)"></circle> <circle cx="245.67175110458567" cy="217.1949486286303" r="5" fill="rgb(30,150,116)"></circle> <circle cx="157.1543105644771" cy="197.82600606935443" r="5" fill="rgb(30,150,45)"></circle> <circle cx="277.47686405127035" cy="159.7874794173272" r="5" fill="rgb(30,150,130)"></circle> <circle cx="233.345787687867" cy="166.3550830285023" r="5" fill="rgb(30,150,84)"></circle> <circle cx="117.83415920099087" cy="164.15103726228338" r="5" fill="rgb(30,150,40)"></circle> <circle cx="120.13909214312396" cy="172.46043638719644" r="5" fill="rgb(30,150,41)"></circle> <circle cx="205.5110421762653" cy="72.98191491764617" r="5" fill="rgb(30,150,102)"></circle> <circle cx="96.80163765991092" cy="62.92764545891779" r="5" fill="rgb(30,150,115)"></circle> <circle cx="124.88959943706861" cy="225.15044973370053" r="5" fill="rgb(30,150,81)"></circle> <circle cx="164.15746228129717" cy="208.86982033897232" r="5" fill="rgb(30,150,58)"></circle> <circle cx="61.99262838338286" cy="146.89828049656404" r="5" fill="rgb(30,150,99)"></circle> <circle cx="172.85767813829926" cy="78.87359339217413" r="5" fill="rgb(30,150,83)"></circle> <circle cx="253.24460591758893" cy="78.41050145160236" r="5" fill="rgb(30,150,132)"></circle> <circle cx="118.82587572803565" cy="135.954087178179" r="5" fill="rgb(30,150,43)"></circle> <circle cx="98.37373962332532" cy="154.76680314997353" r="5" fill="rgb(30,150,60)"></circle> <circle cx="122.31937398668295" cy="165.877836976854" r="5" fill="rgb(30,150,36)"></circle> <circle cx="149.9286260021866" cy="46.27747926759328" r="5" fill="rgb(30,150,115)"></circle> <circle cx="150.6188359447945" cy="196.58148153111807" r="5" fill="rgb(30,150,44)"></circle> <circle cx="96.17812624734673" cy="29.840537240648665" r="5" fill="rgb(30,150,146)"></circle> <circle cx="128.59108692837646" cy="194.72588208165476" r="5" fill="rgb(30,150,50)"></circle> <circle cx="38.82122769921369" cy="75.5662312500352" r="5" fill="rgb(30,150,149)"></circle> <circle cx="79.94903569579193" cy="186.85152375858772" r="5" fill="rgb(30,150,86)"></circle> <circle cx="204.77448960563186" cy="203.64418479165812" r="5" fill="rgb(30,150,73)"></circle> <circle cx="102.88584275265274" cy="197.78063641998918" r="5" fill="rgb(30,150,71)"></circle> <circle cx="159.65478381235536" cy="151.46210092241446" r="5" fill="rgb(30,150,6)"></circle> <circle cx="134.10239921221842" cy="161.49132008992956" r="5" fill="rgb(30,150,23)"></circle> <circle cx="139.09958643074796" cy="219.08371036054947" r="5" fill="rgb(30,150,70)"></circle> <circle cx="146.567509740401" cy="147.39910865707066" r="5" fill="rgb(30,150,12)"></circle> <circle cx="131.83426320463218" cy="162.48898240420658" r="5" fill="rgb(30,150,25)"></circle> <circle cx="173.79168328304365" cy="42.17798379123914" r="5" fill="rgb(30,150,121)"></circle> <circle cx="109.95961714856101" cy="176.03754103367197" r="5" fill="rgb(30,150,52)"></circle> <circle cx="193.05669580827944" cy="188.37810635692216" r="5" fill="rgb(30,150,53)"></circle> <circle cx="104.13084921683644" cy="251.78865585330408" r="5" fill="rgb(30,150,116)"></circle> <circle cx="151.87833723048243" cy="141.41758941633188" r="5" fill="rgb(30,150,14)"></circle> <circle cx="170.37984822769394" cy="82.74727274516178" r="5" fill="rgb(30,150,78)"></circle> <circle cx="269.0943849070194" cy="126.07704256534687" r="5" fill="rgb(30,150,125)"></circle> <circle cx="125.65122538235366" cy="91.64498546299714" r="5" fill="rgb(30,150,74)"></circle> <circle cx="197.53172426918525" cy="128.69408459081865" r="5" fill="rgb(30,150,53)"></circle> <circle cx="174.6642667835747" cy="158.9818125733492" r="5" fill="rgb(30,150,21)"></circle> <circle cx="24.442195159380894" cy="149.95618131450235" r="5" fill="rgb(30,150,138)"></circle> <circle cx="230.57251917564554" cy="160.3740796367529" r="5" fill="rgb(30,150,80)"></circle> <circle cx="116.98152224764455" cy="119.15376321927269" r="5" fill="rgb(30,150,55)"></circle> <circle cx="76.56308571870836" cy="116.27351644357717" r="5" fill="rgb(30,150,92)"></circle> <circle cx="114.18131147378502" cy="228.83119145309104" r="5" fill="rgb(30,150,89)"></circle> <circle cx="61.43526198061147" cy="189.2999144311051" r="5" fill="rgb(30,150,105)"></circle> <circle cx="47.159274262692136" cy="232.7974361297379" r="5" fill="rgb(30,150,141)"></circle> <circle cx="182.3516235175878" cy="147.2513501676052" r="5" fill="rgb(30,150,30)"></circle> <circle cx="212.65566528240188" cy="106.8365872143227" r="5" fill="rgb(30,150,79)"></circle> <circle cx="103.57241974005441" cy="244.94215489038754" r="5" fill="rgb(30,150,110)"></circle> <circle cx="118.74222089776532" cy="72.89123743199185" r="5" fill="rgb(30,150,95)"></circle> <circle cx="249.90029463264338" cy="210.31306906279752" r="5" fill="rgb(30,150,116)"></circle> <circle cx="138.08211482254237" cy="201.93298825621986" r="5" fill="rgb(30,150,53)"></circle> <circle cx="99.45732504409123" cy="125.68120399343496" r="5" fill="rgb(30,150,66)"></circle> <circle cx="95.25417908245312" cy="199.8722971385956" r="5" fill="rgb(30,150,79)"></circle> <circle cx="173.5225523778074" cy="183.25325411366197" r="5" fill="rgb(30,150,35)"></circle> <circle cx="161.10556608174647" cy="287.6615940190875" r="5" fill="rgb(30,150,141)"></circle> <circle cx="99.12828988863924" cy="192.5533080036565" r="5" fill="rgb(30,150,71)"></circle> <circle cx="138.3352868758438" cy="198.47497165114282" r="5" fill="rgb(30,150,49)"></circle> <circle cx="193.78642259086737" cy="131.00758347474238" r="5" fill="rgb(30,150,48)"></circle> <circle cx="232.588767217581" cy="166.3351798078713" r="5" fill="rgb(30,150,83)"></circle> <circle cx="39.31251655429242" cy="177.08833200695184" r="5" fill="rgb(30,150,125)"></circle> <circle cx="185.95704286695798" cy="177.33472005753862" r="5" fill="rgb(30,150,40)"></circle> <circle cx="147.90048340005285" cy="71.10204540244274" r="5" fill="rgb(30,150,89)"></circle> <circle cx="166.8845546562491" cy="172.74666158680589" r="5" fill="rgb(30,150,22)"></circle> <circle cx="277.6246746037615" cy="90.30367358125177" r="5" fill="rgb(30,150,147)"></circle> <circle cx="163.7772455221003" cy="119.59515393163443" r="5" fill="rgb(30,150,38)"></circle> <circle cx="100.8084390756384" cy="179.4519113235002" r="5" fill="rgb(30,150,63)"></circle> <circle cx="232.797670719027" cy="208.95839448193917" r="5" fill="rgb(30,150,100)"></circle> <circle cx="116.20169369192108" cy="215.30258202242675" r="5" fill="rgb(30,150,76)"></circle> <circle cx="129.14679183749018" cy="162.7114418319233" r="5" fill="rgb(30,150,28)"></circle> <circle cx="172.21836963279975" cy="53.36276325209766" r="5" fill="rgb(30,150,109)"></circle> <circle cx="122.18074560789485" cy="31.35034324083615" r="5" fill="rgb(30,150,135)"></circle> <circle cx="234.92525075624567" cy="197.12521379760366" r="5" fill="rgb(30,150,95)"></circle> <circle cx="287.55861698920245" cy="191.54124064684203" r="5" fill="rgb(30,150,146)"></circle> <circle cx="208.95996913096113" cy="86.31885888350531" r="5" fill="rgb(30,150,92)"></circle> <circle cx="117.94515643676408" cy="125.74735207871876" r="5" fill="rgb(30,150,50)"></circle> <circle cx="97.65527429491222" cy="84.40941345270775" r="5" fill="rgb(30,150,96)"></circle> <circle cx="148.98989317857215" cy="107.68365082202222" r="5" fill="rgb(30,150,50)"></circle> <circle cx="83.80736835288073" cy="136.33946071934116" r="5" fill="rgb(30,150,78)"></circle> <circle cx="199.93779378476336" cy="138.9591143291108" r="5" fill="rgb(30,150,50)"></circle> <circle cx="158.33576748574276" cy="205.38810908810458" r="5" fill="rgb(30,150,53)"></circle> <circle cx="157.50068512278443" cy="189.02964217352948" r="5" fill="rgb(30,150,36)"></circle> <circle cx="153.9943950342934" cy="149.63839051508984" r="5" fill="rgb(30,150,5)"></circle> <circle cx="227.12941615549062" cy="152.9883523085731" r="5" fill="rgb(30,150,76)"></circle> <circle cx="206.6719685811751" cy="116.71508779989065" r="5" fill="rgb(30,150,68)"></circle> <circle cx="148.85052880252837" cy="109.67806598750374" r="5" fill="rgb(30,150,48)"></circle> <circle cx="226.66377000731163" cy="61.32427435125567" r="5" fill="rgb(30,150,125)"></circle> <circle cx="66.10772769569768" cy="110.10357863882781" r="5" fill="rgb(30,150,105)"></circle> <circle cx="152.27636978490196" cy="114.5539300162203" r="5" fill="rgb(30,150,43)"></circle> <circle cx="135.56796817958528" cy="127.40915255930368" r="5" fill="rgb(30,150,35)"></circle> <circle cx="195.72769880316034" cy="203.4027436123629" r="5" fill="rgb(30,150,67)"></circle> <circle cx="130.7530263067129" cy="244.7852266812409" r="5" fill="rgb(30,150,98)"></circle> <circle cx="36.438341384815075" cy="210.6090541896294" r="5" fill="rgb(30,150,139)"></circle> <circle cx="176.71218763469287" cy="137.54323300750582" r="5" fill="rgb(30,150,29)"></circle> <circle cx="174.45032008232968" cy="209.2316111886315" r="5" fill="rgb(30,150,61)"></circle> <circle cx="68.73068617514102" cy="52.28176780869747" r="5" fill="rgb(30,150,142)"></circle> <circle cx="162.4456402979608" cy="73.76239706732053" r="5" fill="rgb(30,150,86)"></circle> <circle cx="108.00141921697366" cy="109.55469140282139" r="5" fill="rgb(30,150,69)"></circle> <circle cx="162.96141476843476" cy="141.23102327916624" r="5" fill="rgb(30,150,16)"></circle> <circle cx="125.9345304765698" cy="238.19247603714848" r="5" fill="rgb(30,150,93)"></circle><line x1="130.64433518067872" y1="28.1630727673696" x2="96.17812624734673" y2="29.840537240648665" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="96.17812624734673" y1="29.840537240648665" x2="67.04524904809107" y2="53.02953597638252" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="67.04524904809107" y1="53.02953597638252" x2="38.82122769921369" y2="75.5662312500352" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="38.82122769921369" y1="75.5662312500352" x2="28.36356558991553" y2="95.4663889254756" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="28.36356558991553" y1="95.4663889254756" x2="18.330634507062157" y2="169.68512490920642" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="18.330634507062157" y1="169.68512490920642" x2="19.797156728201166" y2="208.00327375672293" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="19.797156728201166" y1="208.00327375672293" x2="36.83140136457256" y2="237.10836498299798" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="36.83140136457256" y1="237.10836498299798" x2="132.24331417077946" y2="291.2609993001805" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="132.24331417077946" y1="291.2609993001805" x2="161.10556608174647" y2="287.6615940190875" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="161.10556608174647" y1="287.6615940190875" x2="226.2427629753817" y2="260.4928511647599" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="226.2427629753817" y1="260.4928511647599" x2="282.75471021838604" y2="222.40422121056434" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="282.75471021838604" y1="222.40422121056434" x2="287.55861698920245" y2="191.54124064684203" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="287.55861698920245" y1="191.54124064684203" x2="277.6246746037615" y2="90.30367358125177" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="277.6246746037615" y1="90.30367358125177" x2="251.5850563588106" y2="65.40572671380644" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="251.5850563588106" y1="65.40572671380644" x2="204.0380699117014" y2="37.35498291700646" style="stroke:rgb(255,0,0);stroke-width:2"></line> <line x1="204.0380699117014" y1="37.35498291700646" x2="130.64433518067872" y2="28.1630727673696" style="stroke:rgb(255,0,0);stroke-width:2"></line></svg> - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} ---------------------------------------------------------------------------------------------- --- --- GRAHAM SCAN IMPLEMENTATION --- --- This little haskell programm calulates the Convex Hull for a set of 2D points. --- It ships wit a main function that feeds the Graham Scan algorithm with some --- random points and generates a simple SVG of the input points and resulting envelope. --- A simple SVG encoder is included. --- --- Alogrithm used: https://en.wikipedia.org/wiki/Graham_scan --- --- CREDITS -- --- --- Michal Idziorek <m.i@gmx.at> --- 16 December 2017 --- ---------------------------------------------------------------------------------------------- - -import Data.List -import System.Random - ---------------------------------------------------------------------------------------------- - --- GRAHAM SCAN -- - --- Three points are clockwise if ccw < 0. -ccw (p1x,p1y) (p2x,p2y) (p3x,p3y) = (p2x - p1x)*(p3y - p1y) - (p2y - p1y)*(p3x - p1x) - --- Calculate the slope defined by 2 points. (return Infinity, if points are identical). -slope (ax,ay) (bx,by) | (ax,ay ) == (bx,by) = 1/0 -- Infinity - | otherwise = (bx-ax)/(by-ay) - --- Comparison function to sort points counterclockwise (given a reference point). -slope_cmp a b c = compare (slope a c) (slope a b) - --- Comparison function using the y and x coordinates for ordering. -graham_cmp (ax,ay) (bx,by) | ay /= by = compare ay by - | otherwise = compare ax bx - --- Graham scan on prepared data. this will calculate the convex hull. -graham_calc [] hs = hs -graham_calc (x1:xs) hh | length(hh) < 2 = graham_calc xs (x1:hh) -graham_calc xx@(x1:xs) hh@(h1:h2:hs) | ccw x1 h1 h2 < 0 = graham_calc xs (x1:hh) - | otherwise = graham_calc xx (h2:hs) - --- Find the starting point, sort all points counterclockwise and perform the graham scan. -graham xs = graham_calc sortedPoints [] - where minPoint = minimumBy graham_cmp xs - sortedPoints = sortBy (slope_cmp minPoint) xs - ---------------------------------------------------------------------------------------------- - --- XML ENCODING-- - -xml_attr (x:xs) = x++"=\""++(head xs)++"\" " -xml_enc tag attrs body = "<"++tag++" "++xml_attrs++">"++body++"</"++tag++">" - where xml_attrs = unlines $ map xml_attr attrs - --- SVG ENCODING -- - --- hardcoded scaling and panning function -svg_transf x = x*30+5 - -line_to_svg ((x1,y1),(x2,y2)) = xml_enc "line" [["x1",show lx1],["y1",show ly1], - ["x2",show lx2],["y2",show ly2], - ["style", "stroke:rgb(255,0,0);stroke-width:2"]] "" - where lx1=svg_transf x1 - lx2=svg_transf x2 - ly1=svg_transf y1 - ly2=svg_transf y2 - -point_to_svg (x,y) = xml_enc "circle" [["cx",show cx],["cy",show cy],["r","5"], - ["fill","rgb(30,150,"++(show (floor dist))++")"]] "" - where cx=svg_transf x - cy=svg_transf y - dist= (sqrt ((x-5)*(x-5) + (y-5)*(y-5)))*255/8 - - - --- draws SVG points and lines (in hardcoded sizes and colors) -svg_draw p l = xml_enc "svg" [style,["width","330"],["height","330"]] body - where style = ["style", - "background-color:black;border:3px solid green;margin:2px;"] - body = (unlines (map point_to_svg p )) ++ - (unlines (map line_to_svg l )) - --- calculate convex hull and generate svg -svg_graham xs = svg_draw xs (zip hull hull_open) - where hull_open = graham xs - hull = (last hull_open) : hull_open - --- RANDOMIZING -- - -randomPoints g cnt = take cnt (zip r10a r10b) - where r5 = randomRs (0,5) g :: [Double] - r10a =zipWith (+) r5 (drop cnt r5) - r10b =zipWith (+) (drop (2*cnt) r5) (drop (3*cnt) r5) - ---------------------------------------------------------------------------------------------- - --- MAIN -- - --- Note that this is the only place of impurity in this source-file. --- Is is subject to side effects due to I/O (we are writng to stdout) --- and the random number generator. -main = do - g <- newStdGen - putStr (svg_graham (randomPoints g 25)) - putStr (svg_graham (randomPoints g 50)) - putStr (svg_graham (randomPoints g 100)) - putStr (svg_graham (randomPoints g 250)) - putStr (svg_graham (randomPoints g 500)) - putStr (svg_graham (randomPoints g 1500)) - ---------------------------------------------------------------------------------------------- -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/080_blog/00040_Haskell-Projects/00065_Base64-Encoder/index.md b/080_blog/00040_Haskell-Projects/00065_Base64-Encoder/index.md deleted file mode 100644 index 830ed8d..0000000 --- a/080_blog/00040_Haskell-Projects/00065_Base64-Encoder/index.md +++ /dev/null @@ -1,51 +0,0 @@ -Miguel's Naive Base64 Encoder -============================== - February 19, 2018 - -Coded on a winter afterfnoon on 19th Feb 2018 A.D. to fully understand -base64 encoding and play with haskell, which is always an indisputable -pleasure. - -The following lines were written in full awareness that 'libraries' for -this very purpose, which perform way better, are in existence. - -Coded in big anger due to nick's stories about saving his binary format, -encrypted passwords in an ascii config file, featuring -strange letters and characters. - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} --- File: base64.hs -- - -import Data.Char -import Text.Printf -import qualified Data.List as L -import qualified Data.List.Split as T - -toBase64 x = maskBase64 x . toBase64core . asciiToBin . binFill $ x -toBase64core = map base64toDigit . map binToDec . T.chunksOf 6 - -base64toDigit x = (['A'..'Z']++['a'..'z']++['0'..'9']++['+','/']) !! x -binToDec = sum . map (2^) . L.findIndices (=='1') . reverse -asciiToBin = concat . map (\y -> printf "%08b" y) . map ord -binFill x = x ++ (take (fill64length x) $ cycle "\000") - -maskBase64 o x = take (length x - l ) x ++ (take l $ cycle "=") - where l = (fill64length o) - -fill64length x | m==0 = 0 - | otherwise = 3-m - where m=mod (length x) 3 - -main = do - line <- getLine - putStrLn $ toBase64 line -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Example usage, with decoding via `base64 -d` - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} -miguel@megaloman:~$ echo -n "secret haskell" | runghc base64.hs -c2VjcmV0IGhhc2tlbGw= -miguel@megaloman:~$ echo -n "c2VjcmV0IGhhc2tlbGw=" | base64 -d # decode to check -secret haskell -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/080_blog/00040_Haskell-Projects/00120_Lambda-Calculus/index.md b/080_blog/00040_Haskell-Projects/00120_Lambda-Calculus/index.md deleted file mode 100644 index 25c6b83..0000000 --- a/080_blog/00040_Haskell-Projects/00120_Lambda-Calculus/index.md +++ /dev/null @@ -1,38 +0,0 @@ -Lambda Calculus -=============== - - May 2, 2018 - -Playing with Type Quantifiers and Haskell's Rank 2 Type Polymorphsim, -implementing Boolean logic from scratch. We use the conventional -definitions for `True` an `False` also known as Church booleans, after Alonzo Church, who -intruced them along Lambda Calculus in the 1930s [1]. - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} -{-# LANGUAGE Rank2Types #-} - -fTrue :: forall a. a->a->a -fTrue x y = x - -fFalse :: forall a. a->a->a -fFalse x y = y - -fAnd :: (forall a. a->a->a)->(forall a. a->a->a)->(forall a. a->a->a) -fAnd p q = p q p - -fOr :: (forall a. a->a->a)->(forall a. a->a->a)->(forall a. a->a->a) -fOr p q = p p q - -fNot :: (forall a. a->a->a)->(forall a. a->a->a) -fNot p = p fFalse fTrue - -ifThenElse :: (forall a. a->a->a)->(forall a. a->a->a) - ->(forall a. a->a->a)->(forall a. a->a->a) -ifThenElse p a b = p a b - --- Example -- - -main = print $ (ifThenElse fFalse fFalse $ fAnd fTrue $ fNot fFalse) "T" "F" -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - [1] https://en.wikipedia.org/wiki/Lambda_calculus diff --git a/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.glade b/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.glade deleted file mode 100644 index db09761..0000000 --- a/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.glade +++ /dev/null @@ -1,312 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> -<interface> - <requires lib="gtk+" version="3.20"/> - <object class="GtkWindow" id="mainWindow"> - <property name="can_focus">False</property> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="orientation">vertical</property> - <property name="homogeneous">True</property> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="orientation">vertical</property> - <child> - <object class="GtkScrolledWindow" id=" "> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="shadow_type">in</property> - <child> - <object class="GtkTextView" id="hist"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkTextView" id="output"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">False</property> - <property name="cursor_visible">False</property> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkGrid"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_homogeneous">True</property> - <property name="column_homogeneous">True</property> - <child> - <object class="GtkButton" id="1"> - <property name="label" translatable="yes">1</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkButton" id="2"> - <property name="label" translatable="yes">2</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkButton" id="3"> - <property name="label" translatable="yes">3</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkButton" id="4"> - <property name="label" translatable="yes">4</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="5"> - <property name="label" translatable="yes">5</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="6"> - <property name="label" translatable="yes">6</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="7"> - <property name="label" translatable="yes">7</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="8"> - <property name="label" translatable="yes">8</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="9"> - <property name="label" translatable="yes">9</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="0"> - <property name="label" translatable="yes">0</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkButton" id="."> - <property name="label" translatable="yes">.</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkButton" id="="> - <property name="label" translatable="yes">=</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="("> - <property name="label" translatable="yes">(</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkButton" id="+"> - <property name="label" translatable="yes">+</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">4</property> - </packing> - </child> - <child> - <object class="GtkButton" id="-"> - <property name="label" translatable="yes">-</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">4</property> - </packing> - </child> - <child> - <object class="GtkButton" id="*"> - <property name="label" translatable="yes">*</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">4</property> - </packing> - </child> - <child> - <object class="GtkButton" id="/"> - <property name="label" translatable="yes">/</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">4</property> - </packing> - </child> - <child> - <object class="GtkButton" id="CLR"> - <property name="label" translatable="yes">CLR</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="DEL"> - <property name="label" translatable="yes">DEL</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkButton" id=")"> - <property name="label" translatable="yes">)</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">3</property> - </packing> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - </object> -</interface> diff --git a/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.hs b/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.hs deleted file mode 100644 index ec47e05..0000000 --- a/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.hs +++ /dev/null @@ -1,74 +0,0 @@ --- Simple Stupid Calculator demonstrating basic gtk/glade and parsec parser usage -- --- Hacked togeter by Miguel on May 3, 2018 - -{-# LANGUAGE PackageImports #-} -import "gtk3" Graphics.UI.Gtk -import Control.Monad.IO.Class -import Data.ByteString.Char8 (pack,unpack) -import Numeric -import Text.Parsec -import Text.Parsec.Expr -import Text.Parsec.Language -import Text.Parsec.Number (fractional2) -import Text.Parsec.Token - --- parse calculation -- -calc s = case parse expr "" s of Right x -> showFFloat Nothing x "" - _ -> "?" - -table = [ [binary "*" (*) AssocLeft, binary "/" (/) AssocLeft ] - , [binary "+" (+) AssocLeft, binary "-" (-) AssocLeft ] ] - -lexer = makeTokenParser haskellDef -expr = buildExpressionParser table term <?> "expression" -term = parens lexer expr <|> fractional2 False <?> "simple expression" - -binary name fun assoc = Infix (do{ reservedOp lexer name; return fun }) assoc - --- gui for the calculator -- -main = do initGUI - builder <- builderNew - builderAddFromFile builder "calc.glade" - window <- builderGetObject builder castToWindow "mainWindow" - output <- builderGetObject builder castToTextView "output" - outputBuff <- textViewGetBuffer output - hist <- builderGetObject builder castToTextView "hist" - histBuff <- textViewGetBuffer hist - end<-textBufferGetEndIter histBuff - histMark <- textBufferCreateMark histBuff Nothing end True - - let conn = connBtn builder outputBuff - connA = connBtnAct builder outputBuff - - -- connecting buttons -- - sequence_ $ conn <$> map show [0..9] ++ ["+","-","/","*","(",")","."] - - connA "CLR" $ textBufferSetByteString outputBuff (pack "") - connA "DEL" $ manipTextBuff outputBuff (\x -> case x of [] -> []; xs -> init xs) - connA "=" $ do txt<-getTextBuff outputBuff - manipTextBuff outputBuff calc - res<-getTextBuff outputBuff - manipTextBuff histBuff (\x -> x++txt++" = "++res++"\n") - end<-textBufferGetEndIter histBuff - textBufferMoveMark histBuff histMark end - textViewScrollToMark hist histMark 0 $ Just (0,1) - return () - - -- handler to run on window destruction - window `on` deleteEvent $ do liftIO mainQuit - return False - widgetShowAll window - mainGUI - -getTextBuff outputBuff = do start<-textBufferGetStartIter outputBuff - end<-textBufferGetEndIter outputBuff - unpack <$> textBufferGetByteString outputBuff start end True - -manipTextBuff outputBuff action = do txt<-getTextBuff outputBuff - textBufferSetByteString outputBuff (pack $ action $ txt) - -connBtn builder buff label = connBtnAct builder buff label $ - textBufferInsertByteStringAtCursor buff (pack label) - -connBtnAct builder buff label act = do btn <- builderGetObject builder castToButton label - btn `on` buttonActivated $ act diff --git a/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.png b/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.png Binary files differdeleted file mode 100644 index 7cb35c3..0000000 --- a/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/calc.png +++ /dev/null diff --git a/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/index.md b/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/index.md deleted file mode 100644 index 381b017..0000000 --- a/080_blog/00040_Haskell-Projects/00130_Calculator-on-Parsec-and-GTK/index.md +++ /dev/null @@ -1,23 +0,0 @@ -Simple Calculator on Parsec and GTK -=================================== - - May 3, 2018 - -{.img-fluid .border} - -Today I implemented this simple stupid calulator as a side effect of playing -around with parsec [1] and haskells gtk3 [2] bindings, as well as glade [3] - -an interactive user interface designer. - -Source Files ------------- - -* [calc.hs](calc.hs) -* [calc.glade](calc.glade) - -Ref ---- - - [1] https://hackage.haskell.org/package/parsec - [2] https://hackage.haskell.org/package/gtk3 - [3] https://glade.gnome.org/ diff --git a/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/SimpleSvg.hs b/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/SimpleSvg.hs deleted file mode 100644 index 7b44557..0000000 --- a/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/SimpleSvg.hs +++ /dev/null @@ -1,179 +0,0 @@ --- --- Miguel's Simple SVG Generator --- --- Author: Michal Idziorek <m.i@gmx.at> --- Last Update: May 11th, 2018 --- - -{-# LANGUAGE ExistentialQuantification #-} - -module SimpleSvg ( - - svgExample1 -- predefined example canvas - -- you can generate the output string via: - -- putStr $ svgGenerate svgExample1 - - ,svgGenerate -- canvas to svg - - ,svgEmpty -- empty canvas - ,svgAdd -- add to canvas (single) - ,svgAddList -- add to canvas (list) - - ,svgCircle -- circle - ,svgLine -- line - ,svgTriangle -- trianvle - - ,svgFilledCircle -- filled circle - ,svgFilledLine -- filled line - ,svgFilledTriangle -- filled trianvle - - ,svgColor -- colors and shades of gray - ,svgRed - ,svgGreen - ,svgBlue - ,svgWhite - ,svgBlack - ,svgShGray - - - ,svgRedLine -- red line - ,svgBluePoint -- small blue circle - ,svgGreenTriangle -- green triangle - - - ) where - --- CONFIG -- - -svgStrokeWidth = 2 - --- EXAMPLE CANVAS -- - --- Demonstrating how to add a few objects to a light gray 300x200 canvas - -svgExample1 = svgAddList (svgEmpty (svgShGray 200) 300 200) $ - [ svgRedLine (0,0) (200,200) - ,svgRedLine (300,0) (100,200) - ,svgBluePoint (33,133) - ,svgBluePoint (33,22) - ,svgBluePoint (66,25) - ,svgFilledTriangle svgBlack svgWhite (20,20) (100,100) (10,90) - ,svgFilledCircle svgWhite svgGreen (150,120) 30 - ]++ - map (svgBluePoint . (,) 250) [50,60..150] - - --- SHAPES -- - --- A few predefined shapes easing a quickstart as well as serving as an --- example, for how to define them in your own code. - -svgRedLine = svgLine svgRed -svgBluePoint pos = svgCircle svgBlue pos 2 -svgGreenTriangle = svgTriangle svgGreen - - --- Shape construction - -svgLine c (x1,y1) (x2,y2) = - svgShape c (SvgLine (svgCoord x1 y1) (svgCoord x2 y2)) - -svgCircle c (x,y) r = - svgShape c (SvgCircle (svgCoord x y) r) - -svgTriangle c (x1,y1) (x2,y2) (x3,y3)= - svgShape c (SvgTriangle (svgCoord x1 y1) (svgCoord x2 y2) (svgCoord x3 y3)) - -svgFilledLine c1 c2 (x1,y1) (x2,y2) = - svgFilledShape c1 c2 (SvgLine (svgCoord x1 y1) (svgCoord x2 y2)) - -svgFilledCircle c1 c2 (x,y) r = - svgFilledShape c1 c2 (SvgCircle (svgCoord x y) r) - -svgFilledTriangle c1 c2 (x1,y1) (x2,y2) (x3,y3)= - svgFilledShape c1 c2 (SvgTriangle (svgCoord x1 y1) (svgCoord x2 y2) (svgCoord x3 y3)) - -svgShape c1 = SvgPrim c1 (svgNoFill) -svgFilledShape c1 c2 = SvgPrim c1 (svgFill c2) - --- CANVAS -- - -data SvgCanvas = SvgCanvas SvgColor Int Int [SvgPrim] - -svgEmpty c w h = SvgCanvas c w h [] -svgAdd (SvgCanvas c w h xs) x = SvgCanvas c w h (x:xs) -svgAddList (SvgCanvas c w h xs) ys = SvgCanvas c w h (reverse ys++xs) - -svgGenerate (SvgCanvas col width height prims) = - xml_enc "svg" [("height",show height),("width", show width), - ("style","background-color:"++svgGenColor col)] - body - where body = foldl f "" prims - f a x = primToSvg x++a - --- COLORS -- - --- color type along with a few predefined colors to work with - -newtype SvgColor = SvgColor (Int,Int,Int) -svgColor r g b = SvgColor (r,g,b) -svgRed = svgColor 255 0 0 -svgBlue = svgColor 0 0 255 -svgGreen = svgColor 0 255 0 -svgShGray v = svgColor v v v -svgBlack = svgShGray 0 -svgWhite = svgShGray 255 - -svgGenColor (SvgColor (r,g,b)) = "rgb("++show r++","++show g++","++show b++")" - --- the fill color is wrapped inside a Maybe type, since it is optional - -newtype SvgFill = SvgFill (Maybe SvgColor) -svgFill col = SvgFill (Just col) -svgNoFill = SvgFill Nothing - --- SHAPES -- - --- A class for shapes that we want to transform into SVG --- We define instances for circle, line and triangle --- The 2D coordinates are wrapped inside a newtype SvgCoord - -newtype SvgCoord = SvgCoord (Double,Double) -svgCoord x y = SvgCoord (x,y) - -data SvgPrim = forall a.SvgPrimClass a => SvgPrim SvgColor SvgFill a - -class SvgPrimClass a where - getSvg :: a->(String,[(String,String)]) - -data SvgCircle = SvgCircle SvgCoord Double -instance SvgPrimClass SvgCircle where - getSvg (SvgCircle (SvgCoord (x,y)) r) = - ("circle", [("cx",show x),("cy",show y),("r",show r)]) - -data SvgLine = SvgLine SvgCoord SvgCoord -instance SvgPrimClass SvgLine where - getSvg (SvgLine (SvgCoord (x1,y1)) (SvgCoord (x2,y2))) = - ("line", [("x1",show x1),("y1",show y1), - ("x2",show x2),("y2",show y2)]) - -data SvgTriangle = SvgTriangle SvgCoord SvgCoord SvgCoord -instance SvgPrimClass SvgTriangle where - getSvg (SvgTriangle (SvgCoord (x1,y1)) (SvgCoord (x2,y2)) (SvgCoord (x3,y3))) = - ("polygon", [("points",pts)]) - where pts=show x1++","++show y1++" "++ - show x2++","++show y2++" "++ - show x3++","++show y3 - --- transform single primitve to SVG -primToSvg (SvgPrim col (SvgFill fill) prim) = xml_enc tag (attrs++attrs2) "" - where (tag, attrs)=getSvg prim - attrs2=[ ("fill",maybe "none" svgGenColor fill) - ,("stroke",svgGenColor col) - ,("stroke-width",show svgStrokeWidth)] - --- XML ENCODER -- - -xml_enc tag attrs body = "<"++tag++" "++xml_attrs++">"++body++"</"++tag++">" - where xml_attrs = unlines $ map xml_attr attrs - xml_attr (a,v) = a++"=\""++v++"\" " diff --git a/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/index.md b/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/index.md deleted file mode 100644 index 8211ba2..0000000 --- a/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/index.md +++ /dev/null @@ -1,31 +0,0 @@ -A Minimalistic SVG Generator -============================ - - May 11, 2018 - - -A minimalistic SVG generator for my humble requirements. -They might grow someday however... - -The SVG in the following screenshot was generated from the following code -to demonstrate a simple use case. - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines} -svgExample1 = svgAddList (svgEmpty (svgShGray 200) 300 200) $ - [ svgRedLine (0,0) (200,200) - ,svgRedLine (300,0) (100,200) - ,svgBluePoint (33,133) - ,svgBluePoint (33,22) - ,svgBluePoint (66,25) - ,svgFilledTriangle svgBlack svgWhite (20,20) (100,100) (10,90) - ,svgFilledCircle svgWhite svgGreen (150,120) 30 - ]++ - map (svgBluePoint . (,) 250) [50,60..150] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -{.img-fluid .border} - -Source Files ------------- - -* [SimpleSvg.hs](SimpleSvg.hs) diff --git a/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/svg.png b/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/svg.png Binary files differdeleted file mode 100644 index d679fad..0000000 --- a/080_blog/00040_Haskell-Projects/00140_Minimalistic-SVG-Generator/svg.png +++ /dev/null diff --git a/080_blog/00040_Haskell-Projects/00200_Estatico-Page-Maker/index.md b/080_blog/00040_Haskell-Projects/00200_Estatico-Page-Maker/index.md deleted file mode 100644 index 04bb46a..0000000 --- a/080_blog/00040_Haskell-Projects/00200_Estatico-Page-Maker/index.md +++ /dev/null @@ -1,35 +0,0 @@ -# Estático - A Static Website Genertor coded in Haskell - - April 12, 2018 - -About two weeks ago, for personal reasons, I decided to switch my website -from a well known PHP driven CMS solution, to a light and static set -of html pages. - -I used this fact to write my own simple static website generator. -And, Yes... I know there are already hundereds of such genertors -out there, but I wanted to practice Haskell and my masturbatory solution -fits in about 200 lines of code, including comments and type signatures. - -I use pandoc for all the heavy work, as syntax highlighting and parsing -of the markdown files, anyway. - -## Features - -* No Database -* Static Content -* Sitemap derived from Directory Tree -* Simple Markdown Files - -## Try It -You can find the most recent version here and build it with _stack_. - -* [https://gitweb.softwarefools.com/?p=miguel/staticuswww.git](https://gitweb.softwarefools.com/?p=miguel/staticuswww.git) - -__Do not forget to adapt the Makefile to your requirements__ - -## Examples -The only example I know of, is this very page: _idziorek.net_ -You can find it's sources here: - -* [https://gitweb.softwarefools.com/?p=miguel/idziorek\_net.git](https://gitweb.softwarefools.com/?p=miguel/idziorek_net.git) diff --git a/080_blog/00040_Haskell-Projects/index.md b/080_blog/00040_Haskell-Projects/index.md deleted file mode 100644 index 5a0766d..0000000 --- a/080_blog/00040_Haskell-Projects/index.md +++ /dev/null @@ -1,4 +0,0 @@ -Haskell -======= - -Some of my small and tiny Haskell creations and notes. |
