diff options
| -rw-r--r-- | brainfuck.html.markdown | 32 | ||||
| -rw-r--r-- | go.html.markdown | 10 | ||||
| -rw-r--r-- | lua.html.markdown | 15 | ||||
| -rw-r--r-- | objective-c.html.markdown | 10 | 
4 files changed, 36 insertions, 31 deletions
| diff --git a/brainfuck.html.markdown b/brainfuck.html.markdown index 2b7ce4db..9282381f 100644 --- a/brainfuck.html.markdown +++ b/brainfuck.html.markdown @@ -1,11 +1,12 @@  ---  language: brainfuck  contributors: -    - ["Prajit Ramachandran", "http://prajitr.github.io"] +    - ["Prajit Ramachandran", "http://prajitr.github.io/"] +    - ["Mathias Bynens", "http://mathiasbynens.be/"]  --- -Brainfuck is an extremely minimal programming language (just 8 commands) and  -is Turing complete. +Brainfuck (not capitalized except at the start of a sentence) is an extremely +minimal Turing-complete programming language with just 8 commands.  ```  Any character not "><+-.,[]" (excluding quotation marks) is ignored. @@ -27,7 +28,7 @@ There are eight commands:  [ and ] form a while loop. Obviously, they must be balanced. -Let's look at some basic Brainfuck programs. +Let's look at some basic brainfuck programs.  ++++++ [ > ++++++++++ < - ] > +++++ . @@ -45,21 +46,18 @@ print cell #2's value. 65 is 'A' in ASCII, so 'A' is printed to the terminal.  , [ > + < - ] > . -This program reads a character from the user input, copies the character into -another cell, and prints out the same character. - -, reads in a character from the user into cell #1. Then we start a loop. Move -to cell #2, increment the value at cell #2, move back to cell #1, and decrement -the value at cell #1. This continues on until cell #1 is 0, and cell #2 holds -cell #1's old value. Because we're on cell #1 at the end of the loop, move to -cell #2, and then print out the value in ASCII. +This program reads a character from the user input and copies the character into +cell #1. Then we start a loop. Move to cell #2, increment the value at cell #2, +move back to cell #1, and decrement the value at cell #1. This continues on +until cell #1 is 0, and cell #2 holds cell #1's old value. Because we're on +cell #1 at the end of the loop, move to cell #2, and then print out the value +in ASCII.  Also keep in mind that the spaces are purely for readibility purposes. You  -could just as easily write it as +could just as easily write it as:  ,[>+<-]>. -  Try and figure out what this program does:  ,>,< [ > [ >+ >+ << -] >> [- << + >>] <<< -] >>   @@ -73,7 +71,7 @@ problem: at the end of the inner loop, cell #2 is zero. To solve this problem,  we also increment cell #4, and then recopy cell #4 into cell #2.  ``` -And that's Brainfuck. Not that hard, eh? For fun, you can write your own  -Brainfuck programs, or you can write a Brainfuck interpreter in another  +And that's brainfuck. Not that hard, eh? For fun, you can write your own  +brainfuck programs, or you can write a brainfuck interpreter in another   language. The interpreter is fairly simple to implement, but if you're a -masochist, trying writing a Brainfuck interpreter... in Brainfuck. +masochist, try writing a brainfuck interpreter… in brainfuck. diff --git a/go.html.markdown b/go.html.markdown index 4db76a49..3a3800dd 100644 --- a/go.html.markdown +++ b/go.html.markdown @@ -1,4 +1,4 @@ ---- +---  name: Go  category: language  language: Go @@ -46,7 +46,7 @@ func main() {  }  // Functions have parameters in parentheses. -// If there are no parameters, empty parens are still required. +// If there are no parameters, empty parentheses are still required.  func beyondHello() {      var x int // Variable declaration.  Variables must be declared before use.      x = 3     // Variable assignment. @@ -71,7 +71,7 @@ func learnTypes() {  can include line breaks.` // same string type      // non-ASCII literal.  Go source is UTF-8. -    g := 'Σ' // rune type, an alias for uint32, holds a UTF-8 code point +    g := 'Σ' // rune type, an alias for uint32, holds a unicode code point      f := 3.14195 // float64, an IEEE-754 64-bit floating point number      c := 3 + 4i  // complex128, represented internally with two float64s @@ -251,7 +251,7 @@ func learnConcurrency() {      fmt.Println(<-c, <-c, <-c) // channel on right, <- is "receive" operator.      cs := make(chan string)       // another channel, this one handles strings. -    cc := make(chan chan string)  // a channel of channels. +    cc := make(chan chan string)  // a channel of string channels.      go func() { c <- 84 }()       // start a new goroutine just to send a value      go func() { cs <- "wordy" }() // again, for cs this time      // Select has syntax like a switch statement but each case involves @@ -259,7 +259,7 @@ func learnConcurrency() {      // that are ready to communicate.      select {      case i := <-c: // the value received can be assigned to a variable -        fmt.Println("it's a", i) +        fmt.Printf("it's a %T", i)      case <-cs: // or the value received can be discarded          fmt.Println("it's a string")      case <-cc: // empty channel, not ready for communication. diff --git a/lua.html.markdown b/lua.html.markdown index 7325a1cf..369de908 100644 --- a/lua.html.markdown +++ b/lua.html.markdown @@ -125,6 +125,9 @@ f = function (x) return x * x end  -- And so are these:  local function g(x) return math.sin(x) end +local g = function(x) return math.xin(x) end +-- Equivalent to local function g(x)..., except referring +-- to g in the function body won't work as expected.  local g; g  = function (x) return math.sin(x) end  -- the 'local g' decl makes g-self-references ok. @@ -133,6 +136,10 @@ local g; g  = function (x) return math.sin(x) end  -- Calls with one string param don't need parens:  print 'hello'  -- Works fine. +-- Calls with one table param don't need parens +-- either (more on tables below): +print {} -- Works fine too. +  ----------------------------------------------------  -- 3. Tables. @@ -203,7 +210,7 @@ f2 = {a = 2, b = 3}  metafraction = {}  function metafraction.__add(f1, f2) -  sum = {} +  local sum = {}    sum.b = f1.b * f2.b    sum.a = f1.a * f2.b + f2.a * f1.b    return sum @@ -266,7 +273,7 @@ eatenBy = myFavs.animal  -- works! thanks, metatable  Dog = {}                                   -- 1.  function Dog:new()                         -- 2. -  newObj = {sound = 'woof'}                -- 3. +  local newObj = {sound = 'woof'}          -- 3.    self.__index = self                      -- 4.    return setmetatable(newObj, self)        -- 5.  end @@ -301,7 +308,7 @@ mrDog:makeSound()  -- 'I say woof'         -- 8.  LoudDog = Dog:new()                           -- 1.  function LoudDog:makeSound() -  s = self.sound .. ' '                       -- 2. +  local s = self.sound .. ' '                 -- 2.    print(s .. s .. s)  end @@ -322,7 +329,7 @@ seymour:makeSound()  -- 'woof woof woof'      -- 4.  -- If needed, a subclass's new() is like the base's:  function LoudDog:new() -  newObj = {} +  local newObj = {}    -- set up newObj    self.__index = self    return setmetatable(newObj, self) diff --git a/objective-c.html.markdown b/objective-c.html.markdown index 9e9f43e7..926a4a0d 100644 --- a/objective-c.html.markdown +++ b/objective-c.html.markdown @@ -160,7 +160,7 @@ int main (int argc, const char * argv[])      int jj;      for (jj=0; jj < 4; jj++)      { -        NSLog(@"%d,", jj++); +        NSLog(@"%d,", jj);      } // => prints "0,"         //           "1,"        //           "2," @@ -223,7 +223,7 @@ int main (int argc, const char * argv[])  // }  // -/+ (type) Method declarations;  // @end -@interface MyClass : NSObject <MyCustomProtocol> +@interface MyClass : NSObject <MyProtocol>  {      int count;      id data; @@ -241,14 +241,14 @@ int main (int argc, const char * argv[])  + (NSString *)classMethod;  // - for instance method -- (NSString *)instanceMethodWithParmeter:(NSString *)string; +- (NSString *)instanceMethodWithParameter:(NSString *)string;  - (NSNumber *)methodAParameterAsString:(NSString*)string andAParameterAsNumber:(NSNumber *)number;  @end  // Implement the methods in an implementation (MyClass.m) file: -@implementation UserObject +@implementation MyClass  // Call when the object is releasing  - (void)dealloc @@ -271,7 +271,7 @@ int main (int argc, const char * argv[])      return [[self alloc] init];  } -- (NSString *)instanceMethodWithParmeter:(NSString *)string +- (NSString *)instanceMethodWithParameter:(NSString *)string  {      return @"New string";  } | 
