diff options
author | bnewbold <bnewbold@robocracy.org> | 2011-09-21 00:42:50 -0400 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2011-09-21 00:42:50 -0400 |
commit | 226b1e9aabc4a557cd522f4488d9e03492e367f0 (patch) | |
tree | 9725f4b4fc9fe08d046f4e9e2938d8b96b3acda5 | |
parent | 36492bceeec70927e4f20f03ce981852a3813174 (diff) | |
download | knowledge-226b1e9aabc4a557cd522f4488d9e03492e367f0.tar.gz knowledge-226b1e9aabc4a557cd522f4488d9e03492e367f0.zip |
formatting fixes
-rw-r--r-- | software/c.page | 24 | ||||
-rw-r--r-- | software/chromium.page | 3 | ||||
-rw-r--r-- | software/debian.page | 2 | ||||
-rw-r--r-- | software/functional programming.page | 40 | ||||
-rw-r--r-- | software/matlab.page | 26 | ||||
-rw-r--r-- | software/scheme.page | 6 |
6 files changed, 57 insertions, 44 deletions
diff --git a/software/c.page b/software/c.page index 910a5de..ec02db6 100644 --- a/software/c.page +++ b/software/c.page @@ -10,19 +10,19 @@ automagically. Eg, ``p+3`` -> ``0xFEFE0000 + 3 * (sizeof foo)``. Examples of tricky pointer sytax:: - int *ip; - (++*p) - (*p++) - ++(*p) - *(++p) + int *ip; + (++*p) + (*p++) + ++(*p) + *(++p) In the context of references like function declarations, only the size of the first dimension of a multi-dimensional array is free; the others must be specified explicitly:: - void copy_2d_array(int a[][10], int b[][10]); // Ok - void copy_2d_array(int a[][], int b[][]); // Invalid - void copy_2d_array(int a[10][], int b[10][]); // Invalid + void copy_2d_array(int a[][10], int b[][10]); // Ok + void copy_2d_array(int a[][], int b[][]); // Invalid + void copy_2d_array(int a[10][], int b[10][]); // Invalid Negative indexing of arrays is "allowed" (reads ahead of the array in memory); need to check for that case explicitly. @@ -35,10 +35,10 @@ The "update statement" of a for loop gets executed at the /end/ of every loop, which means an iteration variable gets updated once more than might be expected:: - int i; - for(i = 0; i < 10; i++) { - } - printf("%d\n", i); // prints 10, not 9 + int i; + for(i = 0; i < 10; i++) { + } + printf("%d\n", i); // prints 10, not 9 Any 'inline' should probably be 'static' (local linkage). diff --git a/software/chromium.page b/software/chromium.page index d39d599..98182eb 100644 --- a/software/chromium.page +++ b/software/chromium.page @@ -12,7 +12,8 @@ spectacular. The bundled flash player that comes with chromium on linux is pretty nice to boot. As of spring 2010, you can get chromium on debian-based systems by adding the -ppa:chromium-daily/beta and apt-getting 'chromium-browser' (NOT 'chromium'). +``ppa:chromium-daily/beta`` and apt-getting 'chromium-browser' (NOT +'chromium'). Tab-searching ----------------- diff --git a/software/debian.page b/software/debian.page index a36fec8..0bbb2ff 100644 --- a/software/debian.page +++ b/software/debian.page @@ -42,7 +42,7 @@ Some gotchas from installing debian a few times: auto-completion scripts are loaded multiple times; disable this in ``~/.bashrc``? - * For building stuff you want build-essential + * For building stuff you want ``build-essential`` * For the usual system man pages ("Linux Programmer's Manual"), you may need to install 'manpages-dev' diff --git a/software/functional programming.page b/software/functional programming.page index 2858a99..8252d20 100644 --- a/software/functional programming.page +++ b/software/functional programming.page @@ -24,32 +24,32 @@ or variables in layer after layer of functions and just holding on to the outermost layer. For instance, the typical way to write a ``length`` function in python would be:: - def how_long(x): - l = 0 - while x.has_next(): - l = l+1; - x.pop() - return l + def how_long(x): + l = 0 + while x.has_next(): + l = l+1; + x.pop() + return l Using recursion, we could do:: - def how_long_recurse(x): - if x.has_next(): - x.pop() - return how_long_recurse(x) + 1 - else: - return 0 + def how_long_recurse(x): + if x.has_next(): + x.pop() + return how_long_recurse(x) + 1 + else: + return 0 Using the collector paradigm, we could do:: - def add1(x): return x+1; - def how_long_col(x, col): - """call this as how_long_col(<collection>, lambda b: b)""" - if not x.has_next(): - return col(0) - else: - x.pop() - return how_long_col(x, lambda a: col(add1(a))) + def add1(x): return x+1; + def how_long_col(x, col): + """call this as how_long_col(<collection>, lambda b: b)""" + if not x.has_next(): + return col(0) + else: + x.pop() + return how_long_col(x, lambda a: col(add1(a))) The first two ways, the plus one operation is actually executed at any given time, while with the collector implementation we're really creating a diff --git a/software/matlab.page b/software/matlab.page index 16ef567..54daa3d 100644 --- a/software/matlab.page +++ b/software/matlab.page @@ -14,20 +14,26 @@ Matlab Matrix Syntax ------------------ -A = [1,2,3,4] - creates a new matrix -A(1) - selects the first element of a matrix, **zero-indexed** -B = [ [1,2,3], [4,5,6], [7,8,9] ] - creates a one dimensional matrix -:: +Create a new matrix: + + A = [1,2,3,4] + +Select the first element of a matrix, **zero-indexed**: + + A(1) + +Create a one dimensional matrix: + + B = [ [1,2,3], [4,5,6], [7,8,9] ] + + +Create a two dimensional matrix: B = [ [1,2,3], - [4,5,6], - [7,8,9] ] + [4,5,6], + [7,8,9] ] - creates a two dimensional matrix Matrix Operations ------------------ diff --git a/software/scheme.page b/software/scheme.page index 48db68e..57f19aa 100644 --- a/software/scheme.page +++ b/software/scheme.page @@ -1,3 +1,9 @@ +--- +format: rst +toc: no +... + +================== Scheme ================== |