« first day (542 days earlier)      last day (4619 days later) » 

1:09 PM
Can someone help me understand this nested for loop?
string alphabet = "abcdefghijklmnopqrstuvwxyz";
for (int i = 0 ; i != alphabet.size() ; i++)
{
for (int j = 0 ; j != alphabet.size() ; j++)
{
for (int k = 0 ; k != alphabet.size() ; k++)
{
cout << alphabet[i] << alphabet[j] << alphabet[k] << endl;
}
}
}
what is it, that you don't understand?
I don't understand what order they execute in
run it and study the output?
I did, but that's not helping much. My dad was trying to explain it to me and says that first they all execute and output AAA and then the for loop lowest will execute 26 times and say AAB AAC AAD AAE etc
modify the code then, to give you better output
here, for example: ideone.com/vHgDF
prints out which loop is being executed when
1:20 PM
You can also think of it as a counter - here's alphabet replaced by "0123456789": ideone.com/XbL3Z
another useful trick is to just run the code in a debugger. Then you can step through it line by line and see exactly what happens when
This is not a very exciting chat huh
let me get out my juggling objects
We'll make this interesting
you asked for help in understanding some code. You didn't ask for excitement
@43524D if you are new here, please read the second starred message at right
1:25 PM
3 hours ago, by sbi
@Caffeine If you like us, you must be new here.
sbi
sbi
@43524D Ha! If you knew...
Anyway, the excitement here is more tailored to (young) adults, than to 14yo kids. Also, it sometimes requires thinking.
@Collin That is so fugly, I am tempted to move it to the bin.
he he he, monkey
@sbi you just can't see another monkey here
Penguins can fire their poo up to 38 cm. This requires 4 times the force a human is capable of.
Edinburgh Zoo had to erect glass panels after their penguins began pooing on people waiting to see the pandas.
1:28 PM
however I'm all for moving big silly pictures to bin
sbi
sbi
@Abyx What do you mean, another monkey? Stern look.
@sbi well.. maybe "other"? my English is so bad.
sbi
sbi
@Abyx Who is the one monkey, that one would be the other to?? Grumble.
@Abyx gorillas are not monkeys
sbi
sbi
That is a monkey.
1:32 PM
so, you think here are no monkeys?
@sbi at which side?
sbi
sbi
This is an ape.
@sbi But he's dancing. Your monkeys are just violent
sbi
sbi
@Collin Monkeys? Which monkeys? I see only one monkey. Do you see more?
@Abyx Dude, the left one is an ape.
Monkeys have a tail, Apes do not
@sbi oh, now I see the difference
1:35 PM
oh, and lemurs are a whole other ball game
sbi
sbi
> A monkey is a primate of the Haplorrhini suborder and simian infraorder, either an Old World monkey or a New World monkey, but excluding apes. — Wikipedia
@thecoshman They are primates, too, but not monkeys.
> Being an ape, he is known for his violent reaction to most people calling him a "monkey." — The Librarian
@sbi and definitely not primapes :P
@sbi did lemurs branch of before apes and monkeys diverged, or are the a divergence from monkeys
sbi
sbi
@thecoshman I think they are closer to the root of the primates than monkey. (Apes are higher still.) Also, lemurs only survived on Madagascar.
@sbi Monkey and Chimp.. fine
1:41 PM
@sbi so there was a common ancestor to lemurs and monkeys, lets call it lemkeys; and then lemkeys and apes share a common ancestor. Also IIRC lemurs evolved on Madagascar, rather then simple finding there way their
sbi
sbi
Is that non-violent enough for you?
@sbi by any chance do you have a book mark folder full of primate pictures?
sbi
sbi
@thecoshman May I point you to the picture I just posted? It fits my reaction to your attempt to comprehend.
@thecoshman It's called google images.
@sbi do enlighten me
@sbi He does look much friendlier, even if horribly disappointed in my lack of knowledge of primates
1:45 PM
greetings
sbi
sbi
@thecoshman There's a family tree of the primates at Wikipedia. (You might need to scroll down a few lines if you have a low resolution.) That should enlighten you.
so if I am reading that correctly, Lemurs are a relatively early off shot, as such could be considered a very old type of on animal
Morning everyone
Can I place a shameless ad of a room that I've made here?
1:55 PM
right ok.
but feel free to talk about what ever subject it is
being he C++ room, chances are some one also deals with what ever odd ball subject you have
It's where we post music we're listening to while coding.
you mean, like that stupid feature MSN ha[sd]?
or just any music as long it's not Justin Bieber.
2:06 PM
erm, the 'Explicit write access' list for this room makes no sense
unless owners are on the list implicitly?
because all the users on that list have rep enough to use chat
@RMartinhoFernandes you'r Portuguese aren't you?
@thecoshman Yes.
Why?
@LucDanton sure, I can look over it.
Oh yeah, I also meant to tell you
boost::variant<T> is likely to lead to UB if T has reference members :|
Well, I assume. I haven't checked their implementations.
The gist of it is that you can't use placement new to construct over a dead reference or const object, and that extends recursively to types that hold a const member of reference member.
So actually no UB until e.g. operator= destroys and reconstructs such a type.
Er, and boost::variant doesn't destroy the object before placing it?
2:19 PM
And in fact such a type will have deleted assignment operators by default (which Boost.Variant will catch). But it is possible to write struct evil { int& ref; evil& operator=(evil const&) {} };.
And I would expect boost::variant to just use that operator=.
At least, that's what I would do.
So for such a type evil e = { i }; e.~evil(); new (&e) evil { j }; is UB (or maybe it's UB if e is used). And I expect the operator= of Boost.Variant to do that.
@RMartinhoFernandes What if it's boost::variant<evil, int> and the RHS has its int member active?
@LucDanton Wait, why is that UB?
That looks perfectly sane to me.
btw, boost.variant uses two storages, so in assignment it won't use placement new at same location where destructed object was
Paragraph 7 of 3.8.
@Abyx Can't it detect if construction is nothrow and thus do the above?
2:23 PM
@LucDanton Sorry, if I sound stupid, but I don't read that in that paragraph.
@RMartinhoFernandes I presume that the restriction is here to allow an implementation to treat const objects as really, really const, no loopholes allowed. I.e. in const T t = {}; rest_of_the_program(t); std::cout << t;the last statement can't be affected by the rest of the program.
And by that same token, references.
@RMartinhoFernandes Oh wait, is that paragraph 9?
Doesn't mention references though, and no recursive rule.
@LucDanton Ah, that sounds more like it.
If that's const alone though that is manageable.
Paragraph 7 seems to say when in foo f; foo& r = f; f.~foo(); new (&f) foo; is the reference r still valid and can be used to refer to the new foo.
Well that's a relief. I'm glad it turned out okay.
Tbh I didn't expect you to just be okay with taking a look at 700-some lines of code.
2:29 PM
@RMartinhoFernandes your caption, or what ever you want to call it, is in German, so just want ed to ask
Hmm, in StorageFor<int> i; new (&i) int;, what's the storage duration of the integer?
Same as any other use of new, which name escapes me right now. Manual?
@thecoshman Ah. That. It means "I am a polynomial" (I have no idea if "polynomial" is correct German, but the rest is ;) ).
Dynamic storage duration.
2:31 PM
@thecoshman It's from here: theoatmeal.com/comics/atheism
@RMartinhoFernandes I know, whilst I have no chance of writing it correctly, it is one of the few bits of German I know
@LucDanton Ah, so then there's zero chance boost::variant causes UB, unless it uses a const StorageFor.
he he he, oatmeal, what a guy
@RMartinhoFernandes Indeedy.
I do also support const types right now (and I decay them properly).
What should I name a type that can hold either a value of type T, or an error (i.e. an exception)? exceptional<T>?
Btw, I'm not going to look at the variant code now, as I'm still going over the overload things.
:)
@LucDanton variant<T, error>?
2:34 PM
I like what I've done with it recently, although I'm a bit disappointed that GCC won't let me do make_overload(f, g, fallback(h)); have to make-do with putting the fallback(h) in first position for the time being.
@RMartinhoFernandes It can hold any error (i.e. it holds an std::exception_ptr behind the cover).
If you want conceptually speaking an std::future holds such a type. Either a value of a given type, or an exception of any type.
Ah, I see. variant<T, std::exception_ptr> looks ugly.
oh, would you happen to know when gcc added support for nullptr
4.7 I think.
I think nullptr was on 4.6.
Let me check on 4.6.1.
2:36 PM
so chances are, it is my out of data (4.4 [I think]) gcc rather then something I did wrong that made it moan
@thecoshman It wasn't on 4.5, so yes.
Confirmed nullptr sighting on 4.6.3.
4.6.1 has it, so should be from 4.6 on.
how old is 4.4?
Release date appears to be April 21, 2009.
I think those releases have been one year apart each for some time in fact.
oh sweet lord, how did I end up with such an old version
2:39 PM
I struggled for a while to understand why you usede make_overload_over<...>::make instead of just a free function, until I tried to unpack the types on a tuple onto a variadic function template.
can anyone help me change my recursive algorithm into something that uses memoization and can be run very quickly?
erm... fairly sure recursion can run quickley
@RMartinhoFernandes Amusingly enough just today I added some support for e.g. make_overload<Sig0, Sig1, Sig2>(ANNEX_MAKE_OVERLOAD(overloaded_name));.
The trick was suppressing deduction, and then I just forward to make_overload_over.
or to put it another way, that recursion and running quickly are not mutually exclusive
1
Q: How can I pass "Any kind of data" to a function in C++

W. GoemanLets say I have a class Handler with some subclasses like stringhandler, SomeTypeHandler, AnotherTypeHandler. The class Handler defines a method "handle" as a common interface for all the subclasses. The logic to "handle" is ofcourse completely different for the different handlers. So what I nee...

2:40 PM
Well what I mean is that the outputs of my function tend to cluster around the same set of numbers
^ interesting.
@LucDanton Did you get it to work with make_overload<std::tuple<Sig0, Sig1, Sig2>>?
And I'm pretty sure it can be done more quickly than it currently is
> My parents will murder me.
^ ???
@IntermediateHacker he did not do good on exams (Dead that is)
2:42 PM
oh, yeah. I remember, lol
@RMartinhoFernandes I haven't even tried. I still think it's not doable (for having attempted long ago right before I settled on make_overload_over as a compromise). A bit of a shame, as it's usually nicer to pack the signatures into a tuple.
@JohnSmith if(programworking){ if(working fast enough){ leaveitalone(); } else { lookatimporivingit(); } } else { getitworking(); }
I.e. the conflict is that you need the elements of the sequence right away (can't use deduction since the argument is overloaded), but can't partially specialise function templates to match those elements.
It works and isn't fast enough... which is why I am here asking for improvements -_-
2:43 PM
So you have template<typename Sequence> auto make_overload(/* I don't have the elements to expand here!! */) ... :(
Right, that's my conclusion.
In D you can treat tuples and variadic packs the same...
just checked my junk mail. apparently I have won a free Samsung Galaxy Nexus and all I have to do to claim my prize is to give my address, email account password and my dad's ATM PIN. Seems honest and authentic enough...
@JohnSmith how fast is fast enough?
fast enough to run within a day? i don't know
right now it's taking, for all I know, years
what are you calculating?
2:45 PM
@RMartinhoFernandes Well if it come to that I'd rather have overload(overloaded_name) be something first-class in the language; I think overloaded sets make for worse second-class citizens than variadic packs are in C++.
i'm calculating a recursive combinatoric involving binary digits
so your looking to make it roughly 1000 times faster?
Overloaded names would have to be a completely new category of expression…
I.e. the biggest wart here is the ANNEX_MAKE_OVERLOAD macro.
@LucDanton C# calls those things "method groups".
2:46 PM
@JohnSmith Is that like a recurrence relation?
@Potatoswatter Nah, overload(overloaded_name) returning a polymorphic functor is a start good enough.
is this something you can parallel-ise?
They're not exactly first-class in the language, but they are usable.
Not sure if it's a recurrence relation
@RMartinhoFernandes Ah, good point. Maybe polymorphic lambda type will help once that's nailed down.
2:47 PM
lol, I replied, giving my address as 'Muscat City Asylum', password as 'idiot criminal' and the ATM PIN as '111-Big-Mac'.
or does it have to be done sequentially?
@RMartinhoFernandes 'good-enough-class' come right after 'first-class'!
Oh well, I'm going with exceptional<T>. The name I have right now is killing me: maybe_throw<T>.
I can't think of a proper name.
2:49 PM
Is that the optional-with-stored-exception-if-missing deal? Someone here had something like that…
seriously though, reading junk mail is fun. I often do it when bored, it makes me feel so lucky. I won a Toyota Prado only 2 days ago in an anonymous imaginary lottery too. :D
Well, the invariant for optional<T> 'a value of T or nothing'. For exceptional<T> it's 'a value of T or an error' (meaning exception).
optionally_wrong!
Kidding.
anyone willing to take a look?
How about optional_throw? Hmm, that would be good as function name but not for the type.
2:51 PM
@JohnSmith Post code somewhere.
@JohnSmith depending on what you function is doing, you might be able to look into making it (more) parallel-ised and/or making use of pre computed data values
exceptional<T> is more like a variant than optional though.
optional<T> is like variant<empty, T> :P
That's true. So it's variant all the way down.
2:52 PM
Btw, I wrote the boring machinery to manipulate function qualifiers (not sure if it's the proper name) and rewrote overload_element without macros!
@LucDanton How so? The stored exception_ptr is a type erasure, so it's just a binary choice at the variant level, right?
@RMartinhoFernandes All of my attempts failed :( Hence the horrible PP machinery, which would only get horribler given ref-qualifiers for *this.
@JohnSmith well that's some very funky C++ right there :P
@JohnSmith are you 100% sure that this is not looping for ever
@Potatoswatter Yes. variant<T, std::exception_ptr> is in fact the implementation.
i'm very sure
it works... it's just slow
2:54 PM
@LucDanton This is what the final product looks like (plus an additional dispatching step).
what are you actually trying to do?
it seems everyone is talking about things I'm too stupid to understand again... :(
it's a counter
based on a bunch of irrelevant stuff i need not get into
this is just the way i am kicking forth output
but it's slow and i am wondering if the inherent structure of the code can be reworked
it's a very elaborate counter
what does comb do?
n choose k
2:56 PM
If the recursion is recalculating values for the same inputs more than once (like the dumb Fibonacci things you see around), memoizing would indeed help.
@JohnSmith The only useful way to optimize a program with exponential complexity is generally to rethink the math so it's not exponential.
yeah but the problem is that when i apply memoization, there are too many "input variables" and i don't seem to gain any unique sped advantage
it just eats memory
Then there aren't many overlapping sub-problems.
yes
well, there are, I think, because there is a %M operation
%M chains tend to repeat
and I notice a lot of repeating values when I output variables at each step
@JohnSmith Problems are defined by their inputs, not outputs.
2:58 PM
Right
it looks like you need to think about what you are trying to do, not about how you are doing it
the whole point of memoization though is that it will return an output given a set of inputs it's already encountered
At this point the "how" is the question
@JohnSmith If it didn't help, then the algorithm doesn't recurse with the same set of inputs often.
And it's not exponential... it's logarithmic. But it's just large and with lots of repetition
Right, because it currently uses four input variables that don't have a lot of repetition
but the outputs do
and since I have %M operations I am wondering if this can be wrapped up somehow
simplifying the inputs in turn, or figuring out when I can bail out even earlier in the loop given that I've already encountered some particular position earlier
That needs work on the math behind the problem.
3:01 PM
that's what I am asking about
improving the algorithm based on the math it's currently leveraging
and perhaps utilitizing memoization
what sort of values are you putting into this?
I thought I had a use for std::addressof but as it turns out I can just use &storage. Oh well.
I kick it off with counter(x,y,0,1) with x>y
¬_¬ and what the hell are x and y?
okay nevermind
3:04 PM
No, go on
I also don't see where 'c' comes from when you call counter
it's going to result in a lot of tangential explanation that has no bearing on the fundamental math I am trying to optimize here
thanks for your time anyway
I'm sticking with my original 'fix the problem you are trying to solve rather then your solution' stance
Can you repost the link? I promise not to jump to conclusions.
3:06 PM
you're asking about improving an algorithm... that you won't explain?
i think i can memoize based on the results of the modular operation
and stop early then
have I missed something, but is 'memoizing' not recording the output given a certain input to save recalculation?
correct
3:09 PM
how can you do that based on an output?
it's based on an input
the same inputs yield the same outputs
so, would it not be the values of x y i and w you would look at to see if they have happened before?
for instance if you know f(x,y) will always output z then you just "memoize" that f(x,y) outputs z and you don't need to actually calculate f() again
yeah but the problem is that the inputs don't repeat, but the outputs do
i'm trying to somehow filter out i and w from the inputs (or something) so that they do repeat
what about the comb() function?
that is trivial to memoize
not worried about that part
3:13 PM
and have you?
lets see that then
huh? it's just a separate comb() function with inputs stored and re-outputted if already encountered
based off the algorithm in stackoverflow.com/questions/9330915/…
is it possible to parallel-ise this?
unsure, that's out of my ability range
3:15 PM
I don't need to support variant<int[N]> right? Let users do variant<std::array<int, N>>.
I wouldn't bother.
did you link to the correct question? I don't see the connection to yours
you asked about comb()
@thecoshman comb() computes the same thing in that question.
that's the comb() function I am using
3:17 PM
oh I see
I'm adding support for volatile for no other reason other than being generic. And that it comes for free of course; it's not like I want to actually put the effort to have it.
@JohnSmith Yes, because you can speculatively evaluate iterations for k in range(0,y+1, 2). count is the output but it's not an input to the recursive part.
correct
what language are you using?
i'm trying multiple languages
anyways i will figure it out on my own, thanks anyhow
3:20 PM
would something like C++ with cuda be acceptable?
perhaps you could make use of GPU acceleration
It's python, and that's got a much smoother learning curve on the threading
it's also got a giant lock preventing more than one thread from executing Python code at once
I thought python supported multithreading well…
@DeadMG There's more than one Python implementation.
AFAIK PyPy has no GIL.
CPU threads will soon run out and got give you that much benefit. you need to be able to throw a lot of threads at this, such that the for k in range(0,y+1, 2) can be done for all values of K at once
3:21 PM
Q: When a cart flys off an edge and hits another set of tracks, can it keep going?
A: As it stands, launching from one track to another is 100% effective, if you have it lined up.
I love Toady.
@RMartinhoFernandes If it doesn't have a GIL, then I'm smelling an equal learning curve to C++
There's no reason to expect any degree of parallelism will make it fast enough until the actual runtime is known.
yeah
i don't think parallelism is the answer
@DeadMG The suggestion was C with CUDA!
@DeadMG Ah, nevermind, they just considered removing. Turned out too hard to do so.
3:24 PM
why not?
Well, IronPython has no GIL.
:P
if you have 1000 values of K and work on them all at once, you have more or less reduced execution time to a 100th (a fair few things assumed admittedly)
any ways, home time :D
have fun
Better to think Titanic was fake than Forrest Gump was real, as several kids I knew did… but just kids
> Wait, are you saying the war in Gone With The Wind really happened?
3:32 PM
O
M
F
G
@RMartinhoFernandes Did I mention to you my variant support n-ary visitation now?
@Potatoswatter hehe
@LucDanton Yes, you did.
@LucDanton Nise
It's very handy to bring compilation speed to a halt.
@LucDanton On MSVC? I reckon a variadics capable compiler should deal with that pretty swiftly
@RMartinhoFernandes Jython doesn't either. (Jython is actually kind of cool the way you can load in arbitrary Java classes and interact with them in python)
@Collin Oh, right. For similar reasons I suppose :)
@sehe Not really, the number of instantiation can get quite high. E.g. three-way visitation means there are instantiations on the order of a*b*c where a, b, c are the 'size' (number of possible active members) of the arguments.
Let me time that.
Ooh, 3-way visitation!
3:39 PM
@RMartinhoFernandes Although, it looks like jython only implements python 2.5. . IronPython's docs says it supports 2.6.. but it's numbered 2.7 now? Maybe they forgot to update the documents?
@RMartinhoFernandes (It is 2.7 compatible, had to go a few release notes back: ironpython.codeplex.com/releases/view/54498)
Oh wait, it is quite fast lol.
Oh neat, I was missing <functional> in my includes. That timing made me catch that.
2.6s for three-way visitation of three-element variants. Not bad.
That's 34k lines of preprocessed source.
3:43 PM
@LucDanton Will C++ ever get rid of header files? :)
@FredOverflow No, but it could have a child language that might
You mean D?
Making gratuitous use of my expression template instead of hand-writing the polymorphic functor makes the compile time balloon up to 12.6s. Oh dear. Let's time Boost.Phoenix instead.
@FredOverflow That's an example of one that happened. I guess that counts :/
9.5s. That's embarrassing.
3:46 PM
@MooingDuck Yay, do I win something? :)
@FredOverflow no
@RMartinhoFernandes What the hell?
You didn't know?
C++ allows a compiler to precompile all the standard headers and then pull them all in when you include a single one. With a mmap'able precompiled header format, that would be pretty practical… when it catches on, they can introduce #include <std> and we never worry about individual ones again.
FTR, Star Wars was real too.
Except Jar Jar and the midichlorians.
That was artistic license.
3:49 PM
@Potatoswatter I don't think you can precompile templates
@MooingDuck Of course you can.
@RMartinhoFernandes I didn't know that they didn't know.
@MooingDuck Precompile just means parse to AST. A template is little different from an inline function.
I wonder if they realize that WWII was real.
@Potatoswatter alright
3:51 PM
Given that Boost.Phoenix makes the preprocessed source have 134k lines while my C++11 emulation (which takes longer to compile) 'only' nets 36k lines I'm not entirely sold on the 'headers are evil' problem.
Headers are evil because they pollute shit.
That's not the problem I'm having right now though.
what is a potatoswatter anyway
@JohnSmith it's what you use to swat potatoes when they're acting up
3:55 PM
lol
@JohnSmith I always thought it had something to do with cooking...
Alright, I'm adding a converting operator= to variant and I'm done with it.
I just imagine potatoes flying through the air
and someone swatting at their furiously
You got it!
I am going to get a new laptop
any suggestions?
I'm not loaded but I want something decent

« first day (542 days earlier)      last day (4619 days later) »