Author Topic: kata  (Read 5433 times)

0 Members and 1 Guest are viewing this topic.

adarqui

  • Administrator
  • Hero Member
  • *****
  • Posts: 30416
  • who run it.
  • Respect: +7440
    • View Profile
    • Email
kata
« on: April 03, 2013, 04:23:19 am »
0
very important project.


standards:

bash:
 - http://www.linuxjournal.com/content/bash-associative-arrays
 - http://www.adarq.org/lets-nerd-the-f-out/unix-shell-programming-3rd-edition/

C:
intel asm: http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html

C#: http://msdn.microsoft.com/en-us/library/vstudio/ms228593.aspx
 - mono: http://www.mono-project.com/Main_Page
 - http://docs.go-mono.com/
 - http://monodevelop.com/Stetic_GUI_Designer
 - http://www.mono-project.com/DllNotFoundException
Code: [Select]
apt-get install mono-csharp-shell mono-mcs mono-complete

C++: http://msdn.microsoft.com/en-us/library/3bstk3k5.aspx
C++: http://www.ecma-international.org/publications/standards/Ecma-372.htm
 - https://en.wikibooks.org/wiki/C%2B%2B_Programming

Clojure:
- http://java.ociweb.com/mark/clojure/article.html
- clojureScript => https://github.com/clojure/clojurescript
- http://clojure.github.io/clojure/clojure.core-api.html#clojure.core
 - http://clojure.org/reference
 .. http://dev.clojure.org/display/doc/Getting+Started
 - http://tryclj.com/
Code: [Select]
apt-get install clojure clojure-contrib
differences between lisp and clojure: http://clojure.org/lisps

- http://pragprog.com/book/shcloj2/programming-clojure



Erlang: http://www.erlang.org/doc/reference_manual/users_guide.html
- http://www.erlang.org/download/getting_started-5.4.pdf
- http://www.erlang.org/course/course.html
Code: [Select]
apt-get install erlang erlang-examples erlang-ssh erlang-tools erlang-manpages
erl -man io
http://ftp.sunet.se/pub/lang/erlang/examples/examples-2.0.html
http://erlang.org/doc/man/io.html
http://erlang.org/doc/reference_manual/expressions.html#id78268


Golang: http://golang.org/ref/spec
Code: [Select]
apt-get install mercurial
hg clone -u release https://code.google.com/p/go
cd go/src
./all.bash
http://golang.org/doc/effective_go.html
http://golang.org/doc/articles/wiki/
http://golang.org/doc/code.html
http://golangtutorials.blogspot.com/2011/05/table-of-contents.html
http://www.golang-book.com/


Haskell: http://www.haskell.org/haskellwiki/Definition
- http://book.realworldhaskell.org/read/
- http://www.cs.uu.nl/docs/vakken/gont/diktaat.pdf
- http://learnyouahaskell.com/chapters
Code: [Select]
apt-get install ghc6 ghc6-doc
http://www.haskell.org/cabal/download.html

Python: http://docs.python.org/2/reference/
 - http://www.diveintopython.net/toc/index.html
 - http://docs.python.org/2/library/json.html
 - http://docs.python.org/2/tutorial/
 - https://docs.python.org/2/contents.html

Ruby: http://rubyspec.org/
Code: [Select]
apt-get install ruby-1.9.1-dev ruby-1.9.1 ruby-1.9.1-full ruby-1.9.1-examples
http://www.rubyist.net/~slagell/ruby/index.html


Scheme: http://groups.csail.mit.edu/mac/projects/scheme/
Code: [Select]
apt-get install guile-1.8

perl
- book http://modernperlbooks.com/books/modern_perl/
 - http://www.perl.org/books/library.html
- perl modules: http://ods.com.ua/win/eng/program/Perl5Unleashed/ch4.phtml

rust
- http://www.rust-lang.org/
- http://static.rust-lang.org/doc/tutorial.html
- http://static.rust-lang.org/doc/rust.html

dlang:
http://dlang.org/

ARM:
http://www.cnx-software.com/2011/02/10/emulate-an-arm-plaform-with-qemu-on-ubuntu-10-10/

objective C:
http://www.gnustep.org/resources/documentation/Developer/Base/ProgrammingManual/manual.html
Code: [Select]
apt-get install gobj

java:

fortran:
http://gcc.gnu.org/wiki/GFortranGettingStarted
http://gcc.gnu.org/wiki/GFortran
Code: [Select]
apt-get install gfortran gnustep
http://jcip.net.s3-website-us-east-1.amazonaws.com/


r-project:
http://www.r-project.org/


smalltalk:
Code: [Select]
apt-get install gnu-smalltalk
http://stephane.ducasse.free.fr/FreeBooks/BlueBook/Bluebook.pdf
http://www.gnu.org/software/smalltalk/manual/html_node/Using-GNU-Smalltalk.html#Using-GNU-Smalltalk
http://smalltalk.gnu.org/
http://www.canol.info/books/computer_programming_using_gnu_smalltalk/


guile scheme:
Code: [Select]
apt-get install guile
http://www.gnu.org/software/guile/manual/



Code: [Select]
arm  C++      D2      golang   java  node.js  perl  python  rust
C    clojure  erlang  haskell  lua   ocaml    php   ruby    x86  r-project smalltalk fortran



elixir
http://elixir-lang.org/

links:
http://h3rald.com/articles/10-programming-languages/



scala:
http://www.scala-lang.org
http://www.scala-sbt.org/release/docs/Getting-Started/Setup#unix
http://docs.scala-lang.org/cheatsheets/
https://blog.udemy.com/scala-tutorial-getting-started-with-scala



clean:
http://wiki.clean.cs.ru.nl/Clean
http://wiki.clean.cs.ru.nl/Download_Clean
http://wiki.clean.cs.ru.nl/Functional_Programming_in_Clean
http://www.mbsd.cs.ru.nl/papers/cleanbook/CleanBookI.pdf
http://www.inf.ufsc.br/~jbosco/cleanBookI.pdf


sml:
http://only.mawhrin.net/~alexey/sysprogsml.pdf


coq:



curry:
http://www.informatik.uni-kiel.de/~curry/papers/report.pdf
http://www.informatik.uni-kiel.de/~pakcs/download.html


idris:


prolog:
http://www.swi-prolog.org/Download.html
http://cdn.preterhuman.net/texts/computing/programming/Prolog/The%20Art%20of%20Prolog%20%202nd%20Ed%20-%20Leon%20Sterling%20,%20Ehud%20Shapiro.pdf

http://www.swi-prolog.org/pldoc/doc_for?object=manual


coffee:
http://coffeescript.org/


typed coffee:
https://github.com/michaelficarra/CoffeeScriptRedux


typescript:
http://typescript.codeplex.com/documentation


clisp:
http://www.cs.sfu.ca/CourseCentral/310/pwfong/Lisp/1/tutorial1.html
ref man: http://www.cs.cmu.edu/Groups/AI/html/cltl/cltl2.html
http://jtra.cz/stuff/lisp/sclr/


guile:
https://www.gnu.org/software/guile/manual/html_node/

lisp:
http://mitpress.mit.edu/sicp/toc/toc.html

adarqui

  • Administrator
  • Hero Member
  • *****
  • Posts: 30416
  • who run it.
  • Respect: +7440
    • View Profile
    • Email
Re: kata
« Reply #1 on: April 08, 2013, 08:30:58 pm »
0
HASKELL

# haskell suffix
.hs

# set prompt
:set prompt "ghci> "

# Not equal
/=

# !
not

# lists
all elements of list must be same type
[1,2,3]
[1..10]

# join two lists
[1,2] ++ [3,4]

# prepend element to head of list (cons)
1 : [2,3]
'a':"bc"

# difference between '' and ""
['1','2','3']
=> "123"

# var func
let e = exp1

# Types have Capital letter
Type
# variable starts with a lower case letter
variable

# the last result
it

# insert module
:m +Module

# type
:type it
:type 3+2

# print types on everything
:set +t

# strongly typed
must explicitly coerce types if they are mismatched.

# Explicitly testing types (type signature)
1 :: Int
1 :: Char => fails..

# comparisons/tests
odd 1
compare 1 2
compare 'a' 'a'
(compare 1 1) == EQ

# Some list operators
head [1, 2, 3, 4]
tail ['a', 'b', 'c', 'd']
tail "list"
take 2 [1,2,3,4,5] => [1,2]
drop 3 [1,2,3,4,5] => [4,5]



# tuples : Can contain elements of different 'type'
(1, 'a', "hi")
(4, ['a', 'm'], (16, True))

# tuple functions
fst
snd

fst (1,2) => 1
snd (1,2) => 2

# passing an expression to a function
head (drop 4 "azerty")

# lines
lines "hi\nyou\n" => ["hi","you"]

# loading a module
:load bleh.hs

# variables in haskell
Once a variable is bound, it's value does not change.. much different than imperative langs

# non strict evaluation
haskell uses non-strict evaluation, opposite of C

Quote
Identifying a type variable
Type variables always start with a lowercase letter. You can always tell a type variable from a normal variable by context, because the languages of types and functions are separate: type variables live in type signatures, and regular variables live in normal expressions. No comments

It's common Haskell practice to keep the names of type variables very short. One letter is overwhelmingly common; longer names show up infrequently. Type signatures are usually brief; we gain more in readability by keeping names short than we would by making them descriptive.


defining types, streamlining functions.


leftoff:
http://book.realworldhaskell.org/read/defining-types-streamlining-functions.html

adarqui

  • Administrator
  • Hero Member
  • *****
  • Posts: 30416
  • who run it.
  • Respect: +7440
    • View Profile
    • Email
Re: kata
« Reply #2 on: April 13, 2013, 05:10:18 pm »
0
PERL

perldoc bleh

the return from a subroutine determines it's context.

value context: describe's how perl interprets a piece of data
 == enforces numeric context
 eq enforces string context
 can coerce data to various contexts

 my $numeric_x =  0 + $x;  # forces numeric context  <-- ex: force numeric context
    my $stringy_x = '' . $x;  # forces string  context <-- force string context
    my $boolean_x =    !!$x;  # forces boolean context <-- force boolean context

the default scalar variable: $_
the default array variable: @_

many of perl's operators (chomp, chr, ord, lc, length, reverse, print, say, uc, etc) operate on the default scalar variable if no arguments are provided.

use $_ as you would "it" in language

@_ , shift,pop

<$FH> -> equivalent to readline

Variable names always have a leading sigil (or symbol) which indicates the type of the variable's value. Scalar variables (Scalars) use the dollar sign ($). Array variables (Arrays) use the at sign (@). Hash variables (Hashes) use the percent sign (%):

the context of the lvalue can dictate the result, ie, my $first = $hash { $key }; will give $first the first element in the hash

- perl uses :: for namespaces, Blah::bleu
- all namespaces are globally visible

By convention, packages all start with an uppercase letter.

Lexical scope governs the visibility of variables declared with my—lexical variables. A lexical variable declared in one scope is visible in that scope and any scopes nested within it, but is invisible to sibling or outer scopes



You may provide a block to the package declaration:
package Store::Toy
    {
        my $discount = 0.10;
    }

  my $name    = 'Donner Odinson, Bringer of Despair'; <-- Literal string, interpreted literally
    my $address = "Room 539, Bilskirnir, Valhalla"; <-- with double quoted, you can encode \t, \n, \r, \f, \b, etc

A string declaration may cross logical newlines

concatenator operator: .

quote operators: qq (double quoting), q (single quoting)
 qq{ "hi" ok eh }
 q{testing ..}
 q^test^

heredoc syntax for large strings:
 my $k =<< 'EOF'
 ...
 ...
EOF <-- must start at the beginning of the line

modifying file handle: binmode $fh, "mode"
encoding/decoding strings etc. encode() decode()


use underscores instead of commas for large numbers (if you want to separate fields): my $billion = 1_000_000_000

undef value represents an unassigned, undefined, and unknown value.
- undef is false in boolean context

() = empty list

parenthesis do not create lists, commas create lists

range operator to create lists:
my @chars = 'a' .. 'z';
    my @count = 13 .. 27;

Use the qw() operator to split a literal string on whitespace to produce a list of strings:
    my @stooges = qw( Larry Curly Moe Shemp Joey Kenny );

postfix if: say "blah" if $y == 1;
block if: if ($y == 1) { ... }

unless, negated form of if
- blah unless $y == 1;

else if = elsif

terniary conditional operator exists: my $h = 1 ? bleh : blah;


loops:
foreach (1 .. 10)
for my $i (1 .. 10)
for (my $i = 0; $i <= 10; $i += 2)
while()
until()

next bleh ...The next statement restarts the loop at its next iteration.
last bleh ... Ends loop immediately
redo bleh ... The redo statement restarts the current iteration without evaluating the conditional again
continue bleh .. The continue construct behaves like the third subexpression of a for loop;
given bleh... The given construct is a feature new to Perl 5.10. It assigns the value of an expression to the topic variable and introduces a block

labels:

NEXT:
while(1) {
 next NEXT true;
}


Iteration and Scoping
Iterator scoping with the topic variable provides one common source of confusion. Consider a function topic_mangler() which modifies $_ on purpose. If code iterating over a list called topic_mangler() without protecting $_, debugging fun would ensue:

Code: [Select]
    for (@values)
    {
        topic_mangler();
    }

    sub topic_mangler
    {
        s/foo/bar/;
    }

If you must use $_ rather than a named variable, make the topic variable lexical with my $_:

Code: [Select]
    sub topic_mangler
    {
        # was $_ = shift;
        my $_ = shift;

        s/foo/bar/;
        s/baz/quux/;

        return $_;
    }

Using a named iteration variable also prevents undesired aliasing behavior through $_.




Code: [Select]
for (
        # loop initialization subexpression
        say 'Initializing', my $i = 0;

        # conditional comparison subexpression
        say "Iteration: $i" and $i < 10;

        # iteration ending subexpression
        say 'Incrementing ' . $i++
    )
    {
        say "$i * $i = ", $i * $i;
    }


given / when:
Code: [Select]
given (shift)
        {
            when (/paper/)    { say 'You win!' };
            when (/rock/)     { say 'We tie!'  };
            when (/scissors/) { say 'I win!'   };
            default           { say $confused  };
        }


tail calls:
A tailcall occurs when the last expression within a function is a call to another function—the outer function's return value is the inner function's return value
sub bleh { return blah(); |


The builtin goto operator has a form which calls a function as if the current function were never called, essentially erasing the bookkeeping for the new function call.
goto &function;


chomp: Use the chomp builtin to remove line-ending characters from each line. Many novices forget this.




SCALAR:


Perl 5's fundamental data type is the scalar, a single, discrete value. That value may be a string, an integer, a floating point value, a filehandle, or a reference—but it is always a single value. Scalars may be lexical, package, or global (Global Variables) variables.


ARRAYS:
declare array:
- my @array;

index an array, always use scalar sigill
- $array[1]

last index of array:
- $#array;
- $array[-1]

index elements 'from the end':
- $array[-x] <- negative index

If you assign to an index beyond the array's current bound, Perl will extend the array to account for the new size and will fill in all intermediary positions with undef

Assigning to a scalar element of an array imposes scalar context, while assigning to the array as a whole imposes list context.

to clear an array:
- @array = ();

array operators:
- push : push to tail of array
- pop : pop tail of array

unshift : prepends a list of elements to the start of the array and returns the new number of elements in the array.
shift : removes and returns the first element of the array.

The splice operator removes and replaces elements from an array given an offset, a length of a list slice, and replacements. Both replacing and removing are optional; you may omit either behavior
my ($winner, $runnerup) = splice @finalists, 0, 2;

Array slices:
- my @blah = @array[1,5]

magic global: $" ... usually a single space

Code: [Select]
# what's in this array again?
    local $" = ')(';
    say "(@sweet_treats)";
    (pie)(cake)(doughnuts)(cookies)(raisin bread)


Hashes

A hash is a first-class Perl data structure which associates string keys with scalar values

Hashes have two important properties:
1) they store one scalar per unique key
2) they provide no specific ordering of keys.

Declaring a hash:
my %hash;

Assigning values to keys:
$hash{'key'} = value;

Assign multiple values in one statement:
my %hash = {
 'bleh' => blah
};

Novices often always quote string literal hash keys, but experienced developers elide the quotes whenever possible. In this way, the presence of quotes in hash keys signifies an intention to do something different.

use the exists keyword on hashes to figure out if a key exists.

Using exists instead of accessing the hash key directly avoids two problems. First, it does not check the boolean nature of the hash value; a hash key may exist with a value even if that value evaluates to a boolean false (including undef):

keys operator: provides a list of keys

values operator: provides a list of values

each operator: The each operator produces a list of two-element lists of the key and the value:
- my ($addressee, $address) = each %addresses


reset hash iterator:
- keys %blah;

merging two hashes:
Code: [Select]
Hash slices make it easy to merge two hashes:

    my %addresses        = ( ... );
    my %canada_addresses = ( ... );

    @addresses{ keys   %canada_addresses }
              = values %canada_addresses


Locking Hashes
As hash keys are barewords, they offer little typo protection compared to the function and variable name protection offered by the strict pragma. The little-used core module Hash::Util provides mechanisms to ameliorate this.

To prevent someone from accidentally adding a hash key you did not intend (whether as a typo or from untrusted user input), use the lock_keys() function to restrict the hash to its current set of keys. Any attempt to add a new key to the hash will raise an exception. This is lax security suitable only for preventing accidents; anyone can use the unlock_keys() function to remove this protection.

Similarly you can lock or unlock the existing value for a given key in the hash (lock_value() and unlock_value()) and make or unmake the entire hash read-only with lock_hash() and unlock_hash().


PAckages

All global variables and functions declared or referred to after the package declaration refer to symbols within the MyCode namespace. You can refer to the @boxes variable from the main namespace only by its fully qualified name of @MyCode::boxes.

Every package declaration creates a new namespace if necessary and causes the parser to put all subsequent package global symbols (global variables and functions) into that namespace.



To modify the value by reference, use the \ sigill and then the double $$ sigill to modify it:

Modifying a value in place, or returning a reference to a scalar can save memory. Because Perl copies values on assignment, you could end up with multiple copies of a large string. Passing around references means that Perl will only copy the references—a far cheaper operation.

Perl does not offer native access to memory locations. The address of the reference is a value used as an identifier. Unlike pointers in a language such as C, you cannot modify the address or treat it as an address into memory. These addresses are only mostly unique because Perl may reuse storage locations as it reclaims unused memory.



Use the reference operator to create a reference to a declared array:

    my @cards     = qw( K Q J 10 9 8 7 6 5 4 3 2 A );
    my $cards_ref = \@cards;
Any modifications made through $cards_ref will modify @cards and vice versa. You may access the entire array as a whole with the @ sigil, whether to flatten the array into a list or count its elements:

    my $card_count = @$cards_ref;
    my @card_copy  = @$cards_ref;


Hash references

my $hash_Ref = \%hash;
my $x = \%hash_ref;
my $keys = $%hash_ref;
$hash_Ref{'key'} = ...


Function References

sub bleh { print "hi" };
my $fn = \&bleh;
$fn->();




Autovivification
When you attempt to write to a component of a nested data structure, Perl will create the path through the data structure to the destination as necessary:

    my @aoaoaoa;
    $aoaoaoa[0][0][0][0] = 'nested deeply';
After the second line of code, this array of arrays of arrays of arrays contains an array reference in an array reference in an array reference in an array reference. Each array reference contains one element. Similarly, treating an undefined value as if it were a hash reference in a nested data structure will make it so:






OPERATORS



adarqui

  • Administrator
  • Hero Member
  • *****
  • Posts: 30416
  • who run it.
  • Respect: +7440
    • View Profile
    • Email
Re: kata
« Reply #5 on: April 27, 2013, 08:03:08 pm »
0
PYTHON


http://docs.python.org/2/tutorial/
http://docs.python.org/release/1.5.1p1/tut/node50.html
http://docs.python.org/2/library/os.html
http://docs.python.org/2/tutorial/inputoutput.html

shit i just lost all of the python notes i added in here.. instead going to just copy and paste stuff:



def fn(params):
  """ doc string """

everything in python is an object

print fn.__doc__

statically typed language
A language in which types are fixed at compile time. Most statically typed languages enforce this by requiring you to declare all variables with their datatypes before using them. Java and C are statically typed languages.
dynamically typed language
A language in which types are discovered at execution time; the opposite of statically typed. VBScript and Python are dynamically typed, because they figure out what type a variable is when you first assign it a value.
strongly typed language
A language in which types are always enforced. Java and Python are strongly typed. If you have an integer, you can't treat it like a string without explicitly converting it.
weakly typed language
A language in which types may be ignored; the opposite of strongly typed. VBScript is weakly typed. In VBScript, you can concatenate the string '12' and the integer 3 to get the string '123', then treat that as the integer 123, all without any explicit conversion.

find out which module you are in:
print __name__



dictionaries:

>>> d = {"server":"mpilgrim", "database":"master"}
>>> d
{'server': 'mpilgrim', 'database': 'master'}
>>> d["server"]                                   
'mpilgrim'

>>> del d[42]
>>> d
{'server': 'mpilgrim', 'uid': 'sa', 'database': 'master', 'retrycount': 3}
>>> d.clear()

del d["server"]




lists
li = ["a", "b", "mpilgrim", "z", "example"]
>>> li
['a', 'b', 'mpilgrim', 'z', 'example']
>>> li[0]                                       
'a'

>>> li[-1]
'example'

>>> li[1:3] 
['b', 'mpilgrim']

 li
['a', 'b', 'mpilgrim', 'z', 'example']
>>> li[:3]
['a', 'b', 'mpilgrim']
>>> li[3:] 
['z', 'example']
>>> li[:] 
['a', 'b', 'mpilgrim', 'z', 'example']


extend & append
>>> li
['a', 'b', 'mpilgrim', 'z', 'example']
>>> li.append("new")               
>>> li
['a', 'b', 'mpilgrim', 'z', 'example', 'new']
>>> li.insert(2, "new")           
>>> li
['a', 'b', 'new', 'mpilgrim', 'z', 'example', 'new']
>>> li.extend(["two", "elements"])
>>> li
['a', 'b', 'new', 'mpilgrim', 'z', 'example', 'new', 'two', 'elements']

searching:
['a', 'b', 'new', 'mpilgrim', 'z', 'example', 'new', 'two', 'elements']
>>> li.index("example")
5

removing:
['a', 'b', 'new', 'mpilgrim', 'z', 'example', 'new', 'two', 'elements']
>>> li.remove("z")

concatenating lists:
['a', 'b', 'mpilgrim', 'example', 'new']
>>> li += ['two']


tuples
A tuple is an immutable list. A tuple can not be changed in any way once it is created.

>>> t = ("a", "b", "mpilgrim", "z", "example")
>>> t
('a', 'b', 'mpilgrim', 'z', 'example')
>>> t[0] 


   You can't add elements to a tuple. Tuples have no append or extend method.
   You can't remove elements from a tuple. Tuples have no remove or pop method.
   You can't find elements in a tuple. Tuples have no index method.
   You can, however, use in to see if an element exists in the tuple.
So what are tuples good for?

Tuples are faster than lists. If you're defining a constant set of values and all you're ever going to do with it is iterate through it, use a tuple instead of a list.
It makes your code safer if you “write-protect” data that does not need to be changed. Using a tuple instead of a list is like having an implied assert statement that shows this data is constant, and that special thought (and a specific function) is required to override that.
Remember that I said that dictionary keys can be integers, strings, and “a few other types”? Tuples are one of those types. Tuples can be used as keys in a dictionary, but lists can't be used this way.Actually, it's more complicated than that. Dictionary keys must be immutable. Tuples themselves are immutable, but if you have a tuple of lists, that counts as mutable and isn't safe to use as a dictionary key. Only tuples of strings, numbers, or other dictionary-safe tuples can be used as dictionary keys.
Tuples are used in string formatting, as you'll see shortly.



mapping
 v = ('a', 'b', 'e')
>>> (x, y, z) = v     
>>> x
'a'



range
range(7)                                                                   
[0, 1, 2, 3, 4, 5, 6]

concat srings:
k = "uid"
>>> v = "sa"
>>> "%s=%s" % (k, v)
'uid=sa'



mappings

 li = [1, 9, 8, 4]
>>> [elem*2 for elem in li]     
[2, 18, 16, 8


mappings: The keys, values, and items Functions
>>> params = {"server":"mpilgrim", "database":"master", "uid":"sa", "pwd":"secret"}
>>> params.keys()   
['server', 'uid', 'database', 'pwd']
>>> params.values()
['mpilgrim', 'sa', 'master', 'secret']
>>> params.items() 
[('server', 'mpilgrim'), ('uid', 'sa'), ('database', 'master'), ('pwd', 'secret')]




object orientation

ways to import modules:

 import module
 from Module import Module

the second syntax:
This is similar to the import module syntax that you know and love, but with an important difference: the attributes and methods of the imported module types are imported directly into the local namespace, so they are available directly, without qualification by module name. You can import individual items or use from module import * to import everything.


defining classes

class Something:
 ...


'pass' keyword, empty statement


parent classes
class FileInfo(UserDict):
   In Python, the ancestor of a class is simply listed in parentheses immediately after the class name. So the FileInfo class is inherited from the UserDict clas

constructor: __init__

 class Ok:
  """ ok """
  def __init__(params):
    print "hi\n"



class Ok:
 """hi"""
  def __init__(self, params=None):
   print self.params
  def rage():
   print "Raging";

n = Ok()
n.rage()



class: special methods

def __getitem__(self,key): ...
def __setitem__(self,key):...

repr, cmp, delitem, len,

http://www.diveintopython.net/object_oriented_framework/special_class_methods2.html


private class elemnents:
Private functions, which can't be called from outside their module
Private class methods, which can't be called from outside their class
Private attributes, which can't be accessed from outside their class.





random:

try:
...     fsock = open("/notthere")       
... except IOError:                     
...     print "The file does not exist, exiting gracefully"
... print "This line will always print"


try
finally

   This is new: a try...finally block. Once the file has been opened successfully by the open function, you want to make absolutely sure that you close it, even if an exception is raised by the seek or read methods. That's what a try...finally block is for: code in the finally block will always be executed, even if something in the try block raises an exception. Think of it as code that gets executed on the way out, regardless of what happened before.


regex

re.replace()
re.search()

>>> pattern = '^M?M?M?$'
>>> re.search(pattern, 'MM'


adarqui

  • Administrator
  • Hero Member
  • *****
  • Posts: 30416
  • who run it.
  • Respect: +7440
    • View Profile
    • Email
Re: kata
« Reply #6 on: May 10, 2013, 07:16:59 am »
0

adarqui

  • Administrator
  • Hero Member
  • *****
  • Posts: 30416
  • who run it.
  • Respect: +7440
    • View Profile
    • Email
Re: kata
« Reply #7 on: August 27, 2013, 02:51:38 am »
0
RESUMING:

since im so busy at work & it's hard for me to focus on big projects.. I'm resuming this project.

Tonight I made my "hello world's" for each language:

Code: [Select]
arm  C++      D2      golang   java  node.js  perl  python  rust
C    clojure  erlang  haskell  lua   ocaml    php   ruby    x86  r-project smalltalk fortran objective-C

ok well, arm/x86 aren't done yet.. need to figure out what im going to code on for ARM, maybe get a raspberry pi or something.. or use qemu

i might add a few more languages to the mix.. any suggestions? i crossed out C# and scala, not really into the .NET stuff.



This is going to be such a fun project.. i've wanted to do this for a long time, now it's time to focus on it.

maybe I should add a databases folder to the kata project? With redis, mongo, mysql, ... or maybe i should just interface them from the languages above (sounds better).

pC

adarqui

  • Administrator
  • Hero Member
  • *****
  • Posts: 30416
  • who run it.
  • Respect: +7440
    • View Profile
    • Email
Re: kata
« Reply #8 on: August 28, 2013, 08:53:08 am »
0
CURRENT REFERENCES:



quick reference docs:
go: http://golang.org/pkg/time/


redis: http://redis.io/clients

package managers:





redis_1 : playing with redis libraries for various languages
  • C (hiredis)
  • clojure
  • golang
  • D
  • erlang





Stuff i'm currently reading for learning these langs.


In progress:

rust: http://www.rustforrubyists.com/book/book.html
 - leftoff:
golang: http://www.golang-book.com/
 - leftoff:
golang : https://gobyexample.com
 - leftoff:
clojure: http://pragprog.com/book/shcloj2/programming-clojure
 - leftoff:
erlang: "Introducing erlang"
 - leftoff:
erlang : "http://erlang.org/doc/reference_manual"
 - leftoff: http://erlang.org/doc/reference_manual/data_types.html
c++ : C++ Primer, 5th edition
 - leftoff: C2
haskell : http://www.sthaskell.com/
 - leftoff: 3. Types, Typeclasses, and Polymorphism
haskell: http://learnyouahaskell.com/ , http://learnyouahaskell.com/chapters
 - leftoff: http://learnyouahaskell.com/recursion#hello-recursion
elixir : http://elixir-lang.org/getting_started/1.html
 - leftoff:
smalltalk: The Blue Book : http://stephane.ducasse.free.fr/FreeBooks/BlueBook/Bluebook.pdf
 - leftoff:
smalltalk : http://www.canol.info/books/computer_programming_using_gnu_smalltalk/
 - leftoff: C4
guile : http://www.gnu.org/software/guile/manual/guile.html
 - leftoff:
objective C: http://www.gnustep.org/resources/documentation/Developer/Base/ProgrammingManual/manual.html
 - leftoff:
python : Learning python - 4th edition
 - leftoff:
python : diving in : http://www.diveintopython.net/toc/index.html
 - leftoff :
python : think python http://www.greenteapress.com/thinkpython/thinkpython.pdf
 - leftoff : CH 2
ruby: computer science programming basic in ruby
 - leftoff:
java : learning java, 4th edition
 - leftoff:
ocaml : http://caml.inria.fr/pub/docs/oreilly-book/ocaml-ora-book.pdf
- leftoff:
lua: http://www.lua.org/pil/contents.html
 - leftoff: http://www.lua.org/pil/6.html
scala: http://docs.scala-lang.org/tutorials/
 - leftoff:
scala: http://matt.might.net/articles/learning-scala-in-small-bites/
scala: http://twitter.github.io/scala_school/

scala: effective scala : http://twitter.github.io/effectivescala/
 - leftoff:
perl :
 - leftoff:


Completed:
08/31/2013 : clojure : http://java.ociweb.com/mark/clojure/article.html
08/31/2013 : erlang : http://www.erlang.org/download/getting_started-5.4.pdf
09/02/2013: scala : http://scala-lang.org/documentation/getting-started.html




libraries and stuff:

json:
 - go : http://blog.golang.org/json-and-go
 - go : https://gist.github.com/border/775526
 - go : http://stackoverflow.com/questions/13938352/strict-json-parser-in-golang
- c : https://github.com/json-c/json-c
- c : https://github.com/json-c/json-c/blob/json-c-0.11/tests/test2.c

regex:
 - go : https://github.com/StefanSchroeder/Golang-Regex-Tutorial/blob/master/01-chapter1.markdown

ocamlfind:
- http://projects.camlcity.org/projects/findlib.html

hedis/hedisToys:
 - https://github.com/quixoftic/HedisToys

perl redis:
 - http://search.cpan.org/~melo/Redis-1.961/lib/Redis.pm#subscribe

python redis:
https://github.com/andymccurdy/redis-py

ruby:
https://github.com/redis/redis-rb

php redis:
https://github.com/nicolasff/phpredis

java redis:
https://github.com/xetorthio/jedis/

rust redis:
- https://github.com/mneumann/rust-redis
- https://github.com/Seldaek/deris






native php modules:
- http://devzone.zend.com/303/extension-writing-part-i-introduction-to-php-and-zend/
- http://www.kchodorow.com/blog/2011/08/11/php-extensions-made-eldrich-hello-world/
- http://php.webtutor.pl/en/2011/07/07/how-to-create-php-extensions-in-c-part-i-adding-simple-function/

rust kernel modules:
http://thechangelog.com/rust-ko-a-minimal-linux-kernel-module-for-rust/


go worker:
http://www.goworker.org/

adarqui

  • Administrator
  • Hero Member
  • *****
  • Posts: 30416
  • who run it.
  • Respect: +7440
    • View Profile
    • Email
Re: kata
« Reply #9 on: September 01, 2013, 08:31:34 pm »
0

adarqui

  • Administrator
  • Hero Member
  • *****
  • Posts: 30416
  • who run it.
  • Respect: +7440
    • View Profile
    • Email