diff options
-rw-r--r-- | erlang.html.markdown | 2 | ||||
-rw-r--r-- | haskell.html.markdown | 15 | ||||
-rw-r--r-- | java.html.markdown | 2 | ||||
-rw-r--r-- | python.html.markdown | 5 |
4 files changed, 21 insertions, 3 deletions
diff --git a/erlang.html.markdown b/erlang.html.markdown index 66370a7d..42d0b809 100644 --- a/erlang.html.markdown +++ b/erlang.html.markdown @@ -5,7 +5,7 @@ author_url: http://www.focustheweb.com/ filename: learnerlang.erl --- -```latex +```erlang % Percent sign start a one-line comment. %% Two percent characters shall be used to comment functions. diff --git a/haskell.html.markdown b/haskell.html.markdown index 84b8f263..840569fb 100644 --- a/haskell.html.markdown +++ b/haskell.html.markdown @@ -245,7 +245,7 @@ case args of _ -> putStrLn "bad args" -- Haskell doesn't have loops because it uses recursion instead. --- map a function over every element in an array +-- map applies a function over every element in an array map (*2) [1..5] -- [2, 4, 6, 8, 10] @@ -258,6 +258,19 @@ for [0..5] $ \i -> show i -- we could've written that like this too: for [0..5] show +-- You can use foldl or foldr to reduce a list +-- foldl <fn> <initial value> <list> +foldl (\x y -> 2*x + y) 4 [1,2,3] -- 43 + +-- This is the same as +(2 * (2 * (2 * 4 + 1) + 2) + 3) + +-- foldl is left-handed, foldr is right- +foldr (\x y -> 2*x + y) 4 [1,2,3] -- 16 + +-- This is now the same as +(2 * 3 + (2 * 2 + (2 * 1 + 4) + ---------------------------------------------------- -- 7. Data Types ---------------------------------------------------- diff --git a/java.html.markdown b/java.html.markdown index f4ab4220..8ba48d73 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -329,7 +329,7 @@ class Bicycle { } } // end class Bicycle -// Use `extends` to extend a class +// PennyFarthing is a subclass of Bicycle class PennyFarthing extends Bicycle { // (Penny Farthings are those bicycles with the big front wheel. // They have no gears.) diff --git a/python.html.markdown b/python.html.markdown index 59a0b85c..ff77fac6 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -461,6 +461,11 @@ math.sqrt(16) == m.sqrt(16) #=> True # can write your own, and import them. The name of the # module is the same as the name of the file. +# You can find out which functions and attributes +# defines a module. +import math +dir(math) + ``` |