Set operations on ruby arrays

Posted by Nikolaus Gradwohl Sat, 28 Nov 2009 04:23:00 GMT

Ruby provides some very interesting set operations on arrays.

given the two arrays A and B wich look like this

A = ["A", "B", "C", "D"]
B = ["C", "D", "E"]

There are three set operations we can use that union, intersection and difference.

Union

union

A | B

contains all elements from both sets without doublicates. So this results in ["A", "B", "C", "D", "E"]

Difference

difference

A - B

contains all elements from set A that are not in set B. So this results in ["A", "B"]

Intersection

intersection

A & B

contains all elements that are in set A and in set B. So this results in ["C", "D"]

Tags  | no comments

Tweet This! submit to reddit Digg!

Proagwrimo 16 - 22

Posted by Nikolaus Gradwohl Mon, 23 Nov 2009 02:06:00 GMT

45 pages so far. I started making screenshots for the examples, and finished some of the code examples.

Tags  | no comments

Tweet This! submit to reddit Digg!

Pragprowrimo 11-15

Posted by Nikolaus Gradwohl Sun, 15 Nov 2009 05:42:00 GMT

32 pages so far, i added another section and i finished some of the examples for the book. One example for the chapter on interaction will be a litte game. The player has to type some random letters that appear on the screen. After 20 sections the number of found letters is displayed as the score.

click here to give it a try

Tags  | no comments

Tweet This! submit to reddit Digg!

multiple lines in processing

Posted by Nikolaus Gradwohl Thu, 12 Nov 2009 03:57:00 GMT

I wrote a processing-sketch to test how to connect to points using multiple curves that are slightliy shifted by random values. Looks really good in datavisualisation apps.

click here to run the applet and see the code.

multiline

Tags ,  | no comments

Tweet This! submit to reddit Digg!

Pragprowrimo day 8,9,10

Posted by Nikolaus Gradwohl Wed, 11 Nov 2009 02:20:00 GMT

I wrote 26 pages so far, and i startet a new chapter on interaction using audio and video.

Tags  | no comments

Tweet This! submit to reddit Digg!

pragpromwrimo day 5, 6 and 7

Posted by Nikolaus Gradwohl Sat, 07 Nov 2009 09:36:00 GMT

It's a bit chaotic at the moment, but i managed to write at least 1/2 a page every day. I have 21 pages now and i have split up my docbook file in one file per chapter. I also started writing some of the example processing-sketches.

Tags  | no comments

Tweet This! submit to reddit Digg!

Ruby Caldav Library 0.3

Posted by Nikolaus Gradwohl Sat, 07 Nov 2009 06:14:00 GMT

have made a new version of my ruby caldav lib.

version 0.3 is a bugfix release, to make it work with the kde4 calendar

Tags ,  | no comments

Tweet This! submit to reddit Digg!

pragpromwrimo day 3 and 4

Posted by Nikolaus Gradwohl Thu, 05 Nov 2009 03:22:00 GMT

I wrote 4 new pages on the processing book i write for pragprowrimo, and startet to read what i have written. i also fixed some small typos. i think one section needs to be rewritten, but i'm surpriced how well it works so far.

Tags  | no comments

Tweet This! submit to reddit Digg!

pragprowrimo day 2

Posted by Nikolaus Gradwohl Tue, 03 Nov 2009 03:00:00 GMT

I wrote anoter 5 pages of my processing book, and as the praglife blog tells us i haven't tried to correct anything besides syntax-errors in my docbook files yet.

Tags  | no comments

Tweet This! submit to reddit Digg!

pragprowrimo the first day

Posted by Nikolaus Gradwohl Sun, 01 Nov 2009 19:26:00 GMT

The pragmatic programmers have started the Pragmatic Programmers Writing Month and post tips in their pragmatic live blog. The goal is to write 80 pages or more during november.

I have started a book on processing today and managed to write my first 6 pages. i will post my progress on this blog and tag the articles with pragprowrimo

Tags  | 1 comment

Tweet This! submit to reddit Digg!