pages tagged book http://meng6net.localhost/tag/book/ <p><small>Copyright © 2005-2020 by <code>Meng Lu &lt;lumeng3@gmail.com&gt;</code></small></p> Meng Lu's home page ikiwiki Sun, 12 Apr 2020 04:39:09 +0000 间架结构九十二法字帖 http://meng6net.localhost/journal/%E9%97%B4%E6%9E%B6%E7%BB%93%E6%9E%84%E4%B9%9D%E5%8D%81%E4%BA%8C%E6%B3%95%E5%AD%97%E5%B8%96/ http://meng6net.localhost/journal/%E9%97%B4%E6%9E%B6%E7%BB%93%E6%9E%84%E4%B9%9D%E5%8D%81%E4%BA%8C%E6%B3%95%E5%AD%97%E5%B8%96/ book calligraphy Sun, 12 Apr 2020 04:39:09 +0000 2020-04-12T04:39:09Z <ul> <li>黄自元间架结构摘要九十二法</li> <li>欧体楷书间架结构一百二十八法</li> <li>欧体楷书间架结构九十二法</li> <li>欧阳询楷书间架结构九十二法</li> <li>颜体楷书间架结构九十二法</li> <li>柳体楷书间架结构九十二法</li> <li>赵孟頫楷书间架结构九十二法</li> <li>王羲之行书间架结构九十二法</li> <li>魏碑正间架结构九十二法</li> </ul> 《Learn You a Haskell for Great Good!》 study note http://meng6net.localhost/computing/programming/Learn_You_a_Haskell_for_Great_Good_reading_note/ http://meng6net.localhost/computing/programming/Learn_You_a_Haskell_for_Great_Good_reading_note/ Haskell book computing note programming to-do Thu, 18 May 2017 23:35:08 +0000 2017-05-18T23:35:08Z <h2>Introduction</h2> <ul> <li> <p>Haskell is a purely functional programming language.</p> </li> <li> <p>"In purely functional programming you don't tell the computer what to do as such but rather you tell it what stuff is. … You express that in the form of functions. … "</p> </li> <li> <p>A Haskell function cannot have side effects other than mapping its input to an output as a mathematical function.</p> </li> <li> <p>Haskell is lazy in that it does not compute anything until it have to in order to return a value.</p> </li> <li> <p>Haskell is statically typed.</p> <ul> <li>Type inference allows deducing the appropriate type automatically by inference on compatibility between the inputs and outputs.</li> </ul> </li> </ul> <h2>Starting out</h2> <h3>Ready, set, go!</h3> <ul> <li> <p><code>ghci</code>: The Glorious Glasgow Haskell Compilation System. Environment to interactively compile and run Haskell programs. Exit GHCi using <code>:quit</code>. <a href= "http://www.haskell.org/ghc/docs/5.04/html/users_guide/ghci.html">GHCi documentation</a>.</p> </li> <li> <p>Not-equal operator: <code>/=</code>.</p> </li> <li> <p>Compile-time error on incompatible types: <code>123 + "foobar"</code></p> </li> <li> <p>Compile a program: <code>ghci&gt; l:myprogram.hs</code>.</p> </li> <li> <p><code>'</code> is allowed in function name, e.g. <code>foo'Bar</code> is a valid function name.</p> </li> <li> <p>Function names cannot begin with a lower-case letter.</p> </li> </ul> <h3>An intro to lists</h3> <ul> <li> <p>In Haskell, a strings is a lists of characters.</p> </li> <li> <p>List and tuple syntax difference: <code>[1, 2]</code>, <code>(1, "foobar")</code>. A tuple can contain elements of different types, while a list cannot. This bears some similarity with Python's lists and tuples. A difference is that in Python, lists are mutable but tuples are not.</p> </li> <li> <p>Concatenate operation: <code>[1, 2] ++ [3, 4]</code>, <code>"foo" ++ "bar"</code>, <code>['a', 'b'] ++ ['c', 'd']</code>.</p> </li> <li> <p>[https://en.wikipedia.org/wiki/Cons cons] operation <code>:</code>:</p> <pre><code> Prelude&gt; 'f' : "bar" "fbar" Prelude&gt; 1: [3, 4] [1,3,4] Prelude&gt; </code></pre></li> <li> <p>If <code>"XXX...XXX"</code> is a very long string, <code>"XXX...XXX" ++ "foobar"</code> will be slow.</p> </li> <li> <p><code>[1, 2, 3]</code> equals <code>1 : 2 : 3 : []</code>.</p> </li> <li> <p>Take parts of a list: <code>[1, 3, 5, 7] !! 2</code> returns <code>5</code>. Haskell lists uses <a href= "https://en.wikipedia.org/wiki/Zero-based_numbering">zero-based numbering</a>. <code>take 2 [1, 3, 5, 7]</code> gives the third element <code>5</code>. <code>drop 2 [1, 3, 5, 7]</code> gives <code>[1, 3, 7]</code>. Compare this to Mathematica <code>{1,3,5,7}&lt;span class="createlink"&gt;3&lt;/span&gt;</code>, <code>Take[{1,3,5,7}, {3}]</code>, <code>Drop[{1,3,5,7}, {3}]</code>.</p> </li> <li> <p>Test element membership in a list: <code>elem 3 [2, 4, 6]</code> and <code>2 \</code>elem` [1, 3, 5, 7]`.</p> </li> <li> <p><code>[[1, 2], ["foo", "bar"]]</code> is invalid as the types of the elements of the two sub-lists are not same.</p> </li> <li> <p>Lists compare in <a href= "https://en.wikipedia.org/wiki/Lexicographical_order">lexicographical order</a>. E.g. <code>[1, 3, 4] &lt; [1, 4, 2]</code>.</p> </li> <li> <p><code>head [1, 2, 3]</code>, <code>tail [1, 2, 3]</code>, <code>init [1, 2, 3]</code>, <code>last [1, 2, 3]</code>. Compare with Mathematica / Wolfram Langauge namings: <code>First[{1,2,3}]</code>, <code>Rest[{1,2,3}]</code>, <code>Most[{1,2,3}]</code>, <code>Last[{1,2,3}]</code></p> </li> <li> <p><code>null [1, 2, 3]</code>, <code>null []</code></p> </li> </ul> <h2>Other side notes</h2> <ul> <li> <p>One of the key features and advantanges of Haskell is its purity: all side-effects are encapsulated in a monad.</p> </li> <li> <p>[https://en.wikipedia.org/wiki/Algebraic_data type Algebraic data type]:</p> <p>data List a = Nil | Cons a (List a)</p> <p>data Tree = Empty | Leaf Int | Node Tree Tree</p> </li> </ul> <p><code>Tree</code> is a <a href= "https://en.wikipedia.org/wiki/Tagged_union">sum data type</a> a.k.a. tagged union.</p> <p><code>Tree</code> is a <a href= "https://en.wikipedia.org/wiki/Recursive_data_type">recursive data type</a>.</p> <ul> <li> <p>Pattern matching in Haskell:</p> <pre><code> depth :: Tree -&gt; Int depth Empty = 0 depth (Leaf n) = 1 depth (Node l r) = 1 + max (depth l) (depth r) </code></pre></li> </ul> <h2>References</h2> <ul> <li> <p>https://ghcformacosx.github.io/</p> </li> <li> <p>Search a Haskell function by desired type signature, e.g. https://www.haskell.org/hoogle/?hoogle=String+-%3E+Int (And the desired function for turning an object to a <code>String</code> is possibly <code>read :: Read a =&gt; String -&gt; a</code>).</p> </li> </ul> Manufacturing Consent http://meng6net.localhost/journal/manufacturing_consent/ http://meng6net.localhost/journal/manufacturing_consent/ book documentary film journal Sat, 08 Apr 2017 22:21:45 +0000 2017-04-08T22:21:45Z <p>I learned about the book 《Manufacturing Consent: The Political Economy of the Mass Media》 (1988), by Edward S. Herman and Noam Chomsky (<a href="https://chomsky.info/">website</a>) from Aaron Swartz's blog post <a href= "http://www.aaronsw.com/weblog/epiphany">〈The Book That Changed My Life〉</a>. His dramatic description of how he felt after reading the book and watching the documentary film made me extremely interested in them too. I've watched interview to Chomsky in the past but have never read his books.</p> <ul> <li> <p><a href= "https://extratorrent.unblockerproxy.top/download/197368/Manufacturing+Consent+-+Noam+Chomsky+and+the+Media.avi.torrent"> download the torrent file for the documentary film video "Manufacturing Consent: Noam Chomsky and the Media"</a></p> </li> <li> <p><a href= "https://www.goodreads.com/author/list/2476.Noam_Chomsky">a list of some books by Noam Chomsky on goodreads.com</a></p> </li> <li> <p>another famous book by Chomsky 《Understanding Power - The Indispensable Chomsky》(<a href= "https://www.amazon.com/dp/B003XU7IFY/">Amazon</a>)</p> <ul> <li>the companion website: http://understandingpower.com/</li> </ul> </li> </ul>