quick survey for school (2 questions)

Pages: 123
1) Mostly listen to Punk, Rock, Alternative, Metal, Hip Hop, Classical, Rap and Drum&Bass. I listen a little electronical music, but never during coding, really.

2) Under: 17
1) Yes. I don't usually listen to music when coding, but when I do, it may be electronica. (Or waveform, or classical, or acoustic guitar, or rock, or country, etc.)

2) Above.

PS. But not rap or heavy metal.

PPS. ultifinitus's answer can accomodate an arbitrary number of answers.

As an n-tuple:
1
2
3
4
answer.first=true;
answer.second=false;
answer.third=true;
...

As an s-expression:
1
2
3
answer.first=true;
answer.second.first=false;
answer.second.second=true;

;-)
1) Most of the time. More often than not I'll put on something I can listen to without needing to focus on or attend to all that much, so a 1hr+ Vocal Trance mix is very common on my coding playlist. Also pandora.

2) Under
Duoas wrote:
ultifinitus's answer can accomodate an arbitrary number of answers.

Wow, I never thought of that.

So I suppose it looks like this:
1
2
3
4
struct inception {
    struct inception first;
    struct inception second;
};

Is that even possible? I can't see that ever working in C++. Maybe in a language with Lazy Evaluation (IMO the best feature of Haskell and co.).

[edit] Apprently you can do Lazy Evaluation in C++ - http://stackoverflow.com/questions/414243/lazy-evaluation-in-c
That's pretty damn cool.

[edit 2] Nope, the struct above doesn't work.
Last edited on
That's how pairs in Lisp work. A pair is a tuple of two atoms, and an atom can be either a number or a pair. With that, you can construct arbitrary data structures.
The phrase "X can be either a Y or Z" requires an analog of algebraic data types (this isn't the case in Lisp, since atoms aren't implemented in the language). C unions or C++ inheritance would be the closest things.
@chrisname
Remember, though, that the compiler cannot resolve an arbitrarily infinite data structure. That's why you cannot nest structures of the same type:

1
2
3
4
struct A
  {
  A a;  // compile error -- "incomplete/unresolved type" or "infinite recursion" or somesuch
  };

Rather, you need to use pointers:

1
2
3
4
struct A
  {
  A* a;  // fine
  };

The same holds true for tuple lists, or more specifically, s-expressions. Each element can be either an atom (not a pair) or another pair.

1
2
3
4
5
6
7
8
9
10
struct pair
  {
  bool is_pair;       // Is our car an atom or a pair?
  union
    {
    const char* a;    // In this example, our atoms are simple strings
    pair*       p;
    }           car;  // Traditional name for the first element in a pair
  pair*         cdr;  // Traditional name for the second element in a pair
  };

This structure has several characteristics, which can be summarized thus:

null or empty
    
Represented by a pair { false, NULL, NULL }
    Written as ()

atom (in this example, a string)
    
Represented by a pair { false, string, NULL }
    Written as abc, etc.
    (Notice that we never use just a plain const char* -- it must always be wrapped up in a "pair" struct.)

pair
    
Represented by a pair { false, string, pair } or pair { true, pair, pair }
    Written as (abc . cdr) or (abc . cdr)

This last one needs some thought -- a pair is a string or a pair which has been paired with another pair (which may be either an atom or a pair).

Some convenient constructors help:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
pair* new_empty()
  {
  pair* e = new pair;
  e.is_pair = false;
  e.car.s   = NULL;
  e.cdr     = NULL;
  return e;
  }

pair* new_atom( const char* s )
  {
  pair* a = new pair;
  a.is_pair = false;
  a.car.s   = s;
  a.cdr     = NULL;
  return a;
  }

pair* new_atom( pair* p )
  {
  pair* a = new pair;
  a.is_pair = true;
  a.car.p   = p;
  a.cdr     = NULL;
  return a;
  }

pair* new_pair( const char* s, pair* p )
  {
  pair* a = new_atom( s );
  a.cdr = p;
  return a;
  }

pair* new_pair( pair* p1, pair* p2 )
  {
  pair* a = new_atom( p1 );
  a.cdr = p2;
  return a;
  }


You can now represent any arbitrary nested pairs. For example, a proper list is a bunch of nested pairs that terminate with a null (an empty pair). That could be written as:

    (one . (two . (three . ())))

but it is often shortened to just:

    (one two three)


1
2
// list <-- (one two three)
pair* list = new_pair( "one", new_pair( "two", new_pair( "three", new_empty() ) ) );

Without the final null, we would have an improper list, and write it as:

    (one two . three)


1
2
// list <-- (one two . three)
pair* list = new_pair( "one", new_pair( "two", new_atom( "three" ) ) );

If you want to play around with this kind of stuff, be sure to watch for memory leaks!
:-)
Wow, that's pretty cool.
I listen pretty much to anything that is loud, heavy metal, rock, industrial metal, and some electronica/house/techno tracks here and there.

This however is not just limited when I'm coding, I do this all the time, on the net, doing my hw, reading (not literature or poetry, I lose my place often or it doesn't process right in mah head).

And I'm under 25
closed account (1yR4jE8b)
I am turning 25 this month.

I like to listen to techno/dubsteb/electronica when programming: stuff that is generally without lyrics and not particularly agressive.

1. I enjoy The Glitch Mob, Deadmau5 and Daft Punk sometimes, but I also listen to Incubus, Muse and the Chili Peppers, and I've just discovered that Chopin makes me incredibly productive! I also occasionally listen to my own music.
2. Below.
From the choice of musician I can roughly gauge you all age already. Now anyone listen to 70's band? Deep Purple,Black Sabbath,Rainbow came to my mind.

And yes I can see the number 40 rising up in the horizon. Hence my real age can be deduced :P
@ Sohguanh, Ever hear of Klaatu? Their album 'Hope' is on of my all time favorites.
1. No, but I don't listen to electronic music at all. Mostly rock/metal if anything and only if it's something that's either not difficult or not important.

2. I'm 25 :)

May I ask what the point of this survey is?
1. Don't usually listen to music while coding and/or hacking, but sometimes music makes me want to hack something.

2. Sometimes I will slap on a "Tangerine Dream" or an "Enigma" or quite possibly an "Art of Noise" while contemplating the large scale solution to a particular problem. You guessed it, older than 25!
but sometimes music makes me want to hack something.

o.O When you say "hack" what are you talking about? Skiddie stuff- or something else? I've never had music lead me to hacking- though I suppose I could see where you're coming from depending on your definition of hacking.
1. Not often, but it's been known to happen.
2. I am 25.
@ultifinitus, http://catb.org/~esr/faqs/hacker-howto.html
I'm assuming he means hack in the sense described here.

soahguanh, Weather Report was the greatest 70's band, I don't know what you're talking about :/
I'm assuming he means hack in the sense described here.

Ahhh, I see =]

I had assumed he was talking about "cracking"
see: http://en.wikipedia.org/wiki/Hacker_%28computer_security%29
soahguanh, Weather Report was the greatest 70's band, I don't know what you're talking about :/


I guess we are into different music genre. Weather Report seems to veer towards jazz rock is it? I pretty the other realm. Who can forget the all-time classic of Smoke On The Water by Deep Purple? Stairway To Heaven by Led Zeppelin? I'm Eighteen,Poison etc by Alice Cooper?

I got to give full credit to Alice Cooper. A 60's year old guy still at it way before Lady Gaga is born!!!! And he is coming to my country to perform!!!! Long live Alice Cooper! :P

Now I wait for Ozzy Osbourne appearance in my country. He seems to be doing great just like Alice Cooper!

PS I wonder at their age, they must have worn ear-plugs when they perform isn't it? That kind of music is so loud and for some strange reasons it can prolong their life? Hmmm.....
Hehe, except most fantastic musicians end up getting killed in plane crashes or the likes around the age of 30 :/
Pages: 123