C++ woes

Sep 12, 2005 14:11

I haven't coded in C++ in several years. I'm writing some more serious modules now and I've forgotten most of it. I'm relearning how spoiled I am in these silly interpreted languages. Can't break to a label? using namespace std;? #include or #include "math.h" or #include or ...? don't forget that main function. I should stop before I ( Read more... )

c++, cs, lab

Leave a comment

Comments 10

tanjent September 12 2005, 22:36:16 UTC
you're welcome to pester me with questions if you like, i'm a demi-guru.

-tanjent

Reply

lexicat September 13 2005, 00:08:32 UTC
Fortunately I've got C++ coder in the lab to answer most of my WTF questions. I expect there'll be broader questions soon.

For instance, how do I get some Perl map-like functionality? Or is that just too Perlish? It seems amusing to redefine the container class with a map function. That might be quite a challenge. I don't know if I can pass an arbitrary block of code in C++, or just functions.

Not that I need a map function yet, but I'd probably use it if it were easy to make.

Reply

inkyblue2 September 13 2005, 01:40:57 UTC
i don't know dick about perl, but it sounds like you're looking for STL.

Reply

lexicat September 13 2005, 06:53:24 UTC
Buddy, I didn't graduate yesterday. None of the container classes in the STL have a map function (that I've been able to find). There is a Map class, but that's totally unrelated (it's called a hash in Perl).

The map function an operation in individual elements of a vector. It takes a code block and an array, and transmuted each element of the array by the code block and returns the new array. For instance:

@inverted = map { ! $_ } @boolean_array;

This effectively inverts a bit vector.

It's unlikly that C++ can accomplish such a thing with the fluency of Perl. It probably can't even match Python's version of map (called filter). You can read Perl's version here.

Reply


inkyblue2 September 12 2005, 23:52:25 UTC
just learn to enjoy the pain as part of the experience.

Reply

lexicat September 13 2005, 00:04:25 UTC
it's a trial-by-fire, yes. one I should have more thoroghly conquered years ago, yes. I haven't found anything too painful yet though. That will wait for linking!

Reply

inkyblue2 September 13 2005, 01:41:46 UTC
trial? no, no, the pain never goes away. you just start to like it.

Reply


cowbert September 13 2005, 09:21:52 UTC
ahh how one has been corrupted by the loose morals of perl.

Reply


Leave a comment

Up