Erlang for C, C++, and Java Programmers - tamale.net:
An overview of erlang if you already know some programming languages.
(especially C)
'via Blog this'
Pete's occasional blog of shareable collations of random thoughts. Sometimes sardonic often pretentiously sententious. A salacious salvo on Software or Science. A barrage on Society and Citizenry. Skipped pebbles of seditious psephological impertinence. Or the increasingly angst ridden ramblings of the local village neck beard... (have a nice one anyway)
Labels
Australia
Bash
cache
Code
Code Bash
compiler
Cook Islands
Corporatism
Daemons
De-commodification
Debian
Devuan
E17
EarthBuilding
Economics
Energy
enlightenment
Environment
Erlang
Greens
humanity
Janets
Kiribati
ld.so
ldconfig
linking
Linux
Marshall Islands
Music
Nauru
NetBSD
New Zealand
Nuclear
packages
Papua New Guinea
PNG
Politics
Press
Proxy
Python
QandA
Samoa
Science
Services
Society
Solomon Islands
Technology
Thorium
Timor Leste
Tonga
Tuvalu
UN
Vanuatu
Xinetd
Xorg
Tuesday, 19 February 2013
Sunday, 17 February 2013
Neuromorphic engineering - Wikipedia, the free encyclopedia
Place holder....
RN Future Tense had a piece on the "Human Brain Project" which in itslef is notabale, humans have been working on Artificial Intelligence" natural language Processing etal for ... hmmmm hundreds of years. ( depending where you draw that line)
[ say the middleish 1800's ]
quote
http://goparallel.sourceforge.net/neuromorphic-chips-ultimate-parallel-processors/
Spin states are inherent to electrons, which are constantly spinning, imparting a momentum to their electrical charge which can be oriented “up” or “down”. Such spin-polarized electrons can be used to encode digital ones and zeros using much less energy than just piling up charge on a capacitor. Ideally, a single electron could be used to store a digital one as “up” spin and a digital zero as “down” spin, enabling the ultimate downsizing for parallel processors to one-bit-per-electron. And for intrinsically parallel applications, such as emulating the billions of neurons in the human brain, the super low power achieved by spin-polarized digital encodings could enable the ultimate parallel processing applications of the future.
/quote
Neuromorphic engineering - Wikipedia, the free encyclopedia:
Ah the holy Grail.. Analogue and Digital together....
In the Algorithm and the storage.
http://goparallel.sourceforge.net/neuromorphic-chips-ultimate-parallel-processors/
The memristors and "spin" are the partial breakthrough here.
Hmmm maybe the singularity is closer than I thought !
tags:
Quantum Computing, memristors, Analogue Computing
'via Blog this'
RN Future Tense had a piece on the "Human Brain Project" which in itslef is notabale, humans have been working on Artificial Intelligence" natural language Processing etal for ... hmmmm hundreds of years. ( depending where you draw that line)
[ say the middleish 1800's ]
quote
http://goparallel.sourceforge.net/neuromorphic-chips-ultimate-parallel-processors/
Spin states are inherent to electrons, which are constantly spinning, imparting a momentum to their electrical charge which can be oriented “up” or “down”. Such spin-polarized electrons can be used to encode digital ones and zeros using much less energy than just piling up charge on a capacitor. Ideally, a single electron could be used to store a digital one as “up” spin and a digital zero as “down” spin, enabling the ultimate downsizing for parallel processors to one-bit-per-electron. And for intrinsically parallel applications, such as emulating the billions of neurons in the human brain, the super low power achieved by spin-polarized digital encodings could enable the ultimate parallel processing applications of the future.
/quote
Neuromorphic engineering - Wikipedia, the free encyclopedia:
Ah the holy Grail.. Analogue and Digital together....
In the Algorithm and the storage.
http://goparallel.sourceforge.net/neuromorphic-chips-ultimate-parallel-processors/
The memristors and "spin" are the partial breakthrough here.
Hmmm maybe the singularity is closer than I thought !
tags:
Quantum Computing, memristors, Analogue Computing
'via Blog this'
Friday, 15 February 2013
Some Commented Erlang
Was pondering the whole von Neumann bottleneck cf. Quantum computing .....
(LOL not really)
Was reading this python doc on function programming a (longish) while back ...
Decided to go snorkling into concurrent programming etal. ...
So l o n g s t o r y short :
The intention is to learn some sound(er) principles from a number of places and apply them to my work generically where possible, after all why not, it's all good..
FWIW I'll drop some stuff more or less randomly here and make some arrogant pontifications later :)
The primary languages of exploration are Erlang and Python so far... possibly C soonish.
(thats more than I need or possibly even deserve :)
Turns out I have accidentally learnt (a lot) from python anyhow [gasp!] , and even applied some rudiments to my standard bash approach. [ bigger gasp :>]
IMHO Erlang seems to have an _undeserved_ "hairy" reputation.
Here is a commented (day 2 level) Erlang module.
I extended it slightly and added comments that helped me.
Perhaps they may help somebody else.
Mostly from an excellent Erlang course ,.
-module(mathStuff).
-export([factorial/1, area/1]).
%% from www.erlang.org/course/sequential_programming.html
%% (not original) -author('pete@ruthie.tux').
%%%% area :: calculate square circle or triangle areas
%%%% match atom to evaluate Variables
area({square, Side}) -> % this tuple made of: {atom, Variable}
Side * Side;
area({rectangle, Length, Width}) -> % this made of {atom, Variable, Variable}
Length * Width;
area({circle, Radius}) -> % well almost PI is NAN (here we only do radii)
3.14 * Radius * Radius;
area({triangle, A, B, C}) ->
S = (A + B + C)/2,
math:sqrt(S*(S-A)*(S-B)*(S-C));
%% that must be inside -> out eval ... like "normal"
area(Other) ->
{woops_invalid_tuple_content, Other}. % any un matched atom spit error
%%%% single parameter only exported at module head ?
%%%% Its OK we require {a, {tuple, as}} input parameter(s)
%% return the factorial of the single parameter
%% disallow div by 0 ! It really hurts. (fire extinguisher required)
%% a guarded function in two clauses
factorial(N) when N > 0 ->
N * factorial(N - 1);
factorial(0) -> 1.
The code would live in a module (file) named mathStuff.erl and be compiled from
the erl shell or whatever method (emacs etc) you like.
e.g.
~/ erl
Eshell V5.9.1 (abort with ^G)
1> c(mathStuff.erl).
{ok,mathStuff}
2>
(on a perfect day :)
It will compile the x.erl file > x.beam file.
Everything is named the same.
There are header (.hrl z :) files as well and includes may have records, even "macros" etc ... just haven't got to them yet.
From an erl shell (and the same directory for simplicity) you can call this like so:
61> mathStuff:area({triangle, 3, 4, 5}).
6.0
(the 61st thing I had done in the shell)
So the area of the triangle is 6 whatevers ... great :)
We asked the module mathStuff for its exported function area() to "process" (->)
the tuple {triangle, 3, 4, 5}
or
62> mathStuff:factorial(3).
6
63> mathStuff:factorial(6).
720
Random Observations so far.
module:foo() is way more readable than most anything else I have seen.
(yeah I know you can intit to whatever candy you like in most languages.)
Erlangs reads reasonably easily even after just an hour or two.. once you see where "output" is coming from. There need be no print() though there is a thing similar to "printf".
One of the ideas is to have no side-effects
(and bounce / break on invalid input.)
Actually a core idea is to NOT muck about (as much) with allocated memory.
This language cleans up ASAP as well.
Lots to grok if you haven't seen Erlang before but its actually elegant and simple.
If you are used to python you wont have issue with the function structures think of them as
if elseifs or case switch statements ... though you wont for long. :)
A function is simply a collection of clauses to match and ends with a full stop.
Think of the fullstop as "complete ! Now Grunge".
Yep there are Objects. (well not formal classes (yet) but I guess you could )
(go use python or java or C++ or Perl)
Variables Must Have At Least The First Letter Capitalised.
Variables once bound are not reset (per instance) if you try it crashes the function.
(and quite loudly too :)
So there are no i++ (or "normal" loops) for example., and no need.
Emacs has very good support for the language. And you can run a shell in a second window.
(and learn elisp someday)
The Erlang Docs site has excellent documentation about the hows and whys.
If nothing else browse the site and contemplate:
concurrency parallelism
"threads" Processes
imperative VS declarative .
functional programming [1]
(or not :)
And yep I did div/0 , not a good look.
Mind you I've seen worse runaways.
apt-cache search erlang
(or whatever your nix does)
[1] see also: the extended python docs (comes with a full install) about this.
Its what got me wondering about it all.
Erlang and the ancient " 3, 4, 5, [6]" rule
Finally got round to starting to learn Erlang.
So far all good and great for my head... possibly even my "coding".
Actually its a Neat language. Well worth learning if only for the conceptual journey.
So I was doing a "just above beginner" type exercise and playing around and having lots of
AH HA / OH NO moments (as ya do).
When I realised that another "Rule" that has been incredibly useful to me for more than 30 years can safely be extended .
The ancient (seriously like pre pyramid ancient) 3:4:5 triangle rule can run one more increment. ( to um 6 ).
see:
http://www.wikihow.com/Use-the-3-4-5-Rule-to-Build-Square-Corners
For a more fullsome grok.
That is
a triangle of any nominal units (say cubits or rake handles or even meters :) when layed out with:
side A @ 3 Units
side B @ 4 Units
side C at 5 Units
Will give you a perfect 90 degree (and thereby 2 X 45 degree) corner(s).
This is really useful when laying out large objects or building sites or for basic surveying contour mapping, cutting large sheets ... etc.
I have used it many times indoors and out.
Those same numbers give sane ratios of measurement but reducing the 4 to 2 .
(um later maybe !)
simply put :
Try to design large things so the dimension divide by 2 and or 3.
[ no, just try it, you'll see when you try to buy materials :]
The next step is that that same triangle will have an area of 6 Units.
Man how did I miss that ! (DOH)
So now its the 3,4,5,6 rule for me :)
The *ping* moment happened when I was contemplating "guarding" a function that just happened to be about the area of a triangle and had another clause about circles.
(with some earth building mentally back-grounding I expect)
The human brain (or what I pass off as one) is great at associating random stuff into places it has no business being, (in engineering terms).
p.s.
Oh and, of course, there is also the 5,4,3 rule ... sheeze shouda known !
(for Ethernet Networking)
5 4 3 (2 1) rule
So far all good and great for my head... possibly even my "coding".
Actually its a Neat language. Well worth learning if only for the conceptual journey.
So I was doing a "just above beginner" type exercise and playing around and having lots of
AH HA / OH NO moments (as ya do).
When I realised that another "Rule" that has been incredibly useful to me for more than 30 years can safely be extended .
The ancient (seriously like pre pyramid ancient) 3:4:5 triangle rule can run one more increment. ( to um 6 ).
see:
http://www.wikihow.com/Use-the-3-4-5-Rule-to-Build-Square-Corners
For a more fullsome grok.
That is
a triangle of any nominal units (say cubits or rake handles or even meters :) when layed out with:
side A @ 3 Units
side B @ 4 Units
side C at 5 Units
Will give you a perfect 90 degree (and thereby 2 X 45 degree) corner(s).
This is really useful when laying out large objects or building sites or for basic surveying contour mapping, cutting large sheets ... etc.
I have used it many times indoors and out.
Those same numbers give sane ratios of measurement but reducing the 4 to 2 .
(um later maybe !)
simply put :
Try to design large things so the dimension divide by 2 and or 3.
[ no, just try it, you'll see when you try to buy materials :]
The next step is that that same triangle will have an area of 6 Units.
Man how did I miss that ! (DOH)
So now its the 3,4,5,6 rule for me :)
The *ping* moment happened when I was contemplating "guarding" a function that just happened to be about the area of a triangle and had another clause about circles.
(with some earth building mentally back-grounding I expect)
The human brain (or what I pass off as one) is great at associating random stuff into places it has no business being, (in engineering terms).
p.s.
Oh and, of course, there is also the 5,4,3 rule ... sheeze shouda known !
(for Ethernet Networking)
5 4 3 (2 1) rule
Subscribe to:
Posts (Atom)
A Local Devuan Package Mirror (( with Xinetd and approx )) Verbose Version A shorter simpler version is also available (one ...
-
Scripting Stuff I spent some time writing this script, mostly because I wanted something "real" to try parameter substitution o...
-
Following is an hand formatted copy of the Majuro Declaration for Climate Leadership. The Majuro Declaration Web Site. The Canonical Sourc...
-
ALP Think Tank - Home The ALP has a section of their website called the Think Tank. Here members may suggest policy ideas, even discus a...