|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
Hey guys! looking for a bit of help with conceptualizing two objects each holding a reference to a list of the other object.
Im not sure whether to store a reference of the list or the actual list itself in each object. And do I initialize the the list in the constructor or call a method?
basically im reading in a large database file, that's split into two parts, each part creates numerous amounts of the same object.
Now the part I'm having confusion with: each object holds a list that associates itself to numerous specific objects in the other part of the database file and vice versa. So I really have no idea how to initialize each list for each object.
|
|
|
|
|
Officially naming all of my exceptions up from now on.
|
musings on cpp parameter pack expansion
why can't you expand parameter packs like so:
template<class type> int function0(){}
template<class... types> void function1(){ function0<types>()...; } i think it would be nice if it was equivalent to (comma operator on result of function calls):
template<class type> int function0(){}
template<class... types> void function1(){ function0<typename type_at<0,types...>::type>(), function0<typename type_at<1,types...>::type>(), ... function0<typename type_at<sizeof...(types)-1,types...>::type>(); } if function0's return type was not void you could do:
template<class... types> eat(types...){}
template<class type> int function0(){}
template<class... types> void function1(){ eat(function0<types>()...); } or:
template<class type> int function0(){}
template<class... types> void function1(){ auto dummy={function0<types>()...}; } but it's awkward (and doesn't work for void) and this seems like an oversight (unlike expanding parameter packs into switch cases like i posted earlier which probably is more difficult).
another workaround that works for void return type as well is:
template<class type> void function0(){}
template<class... types> void function1(){
static constexpr std::array< void(*)(), sizeof...(types) > functions{ function0<types>... };
for(auto function:functions) function();
}
note that the type of the array needs to be explicit and not deduced (by auto) because deduction fails, not just because i like being explicit about types (maybe you should be able to give it a hint auto(array<_1,_2>)).
also it would be sweet if you could reverse parameter packs like so:
template<class type> void function0(){}
template<class... types> void function1(){
static constexpr std::array< void(*)(), sizeof...(types) > functions{ function0<types>... };
for(auto function:functions) function();
static constexpr std::array< void(*)(), sizeof...(types) > reversed_functions{ ...function0<types> };
for(auto reversed_function:reversed_functions) reversed_function(); } that the first reversed_function call is function0 instantiated with the last type in the parameter pack, and so on.
recursive expansion would also be sweet, but i haven't managed to come up with a good syntax (using @ for now). that is, the expansion (and the reverse expansion) would be equivalent to:
(function<types>@)() function0<typename type_at<sizeof...(types)-1>::type>( ... function0<typename type_at<1>::type>( function0<typename type_at<0>::type>() ) ) and reversed:
(@function<types>)() function0<typename type_at<0>::type>( ... function0<typename type_at<sizeof...(types)-2>::type>( function0<typename type_at<sizeof...(types)-1>::type>() ) )
|
On September 18 2014 07:22 dapierow wrote: Hey guys! looking for a bit of help with conceptualizing two objects each holding a reference to a list of the other object.
Im not sure whether to store a reference of the list or the actual list itself in each object. And do I initialize the the list in the constructor or call a method?
basically im reading in a large database file, that's split into two parts, each part creates numerous amounts of the same object.
Now the part I'm having confusion with: each object holds a list that associates itself to numerous specific objects in the other part of the database file and vice versa. So I really have no idea how to initialize each list for each object.
I am not entirely sure if I completely understand what you are trying to do, but a nice way to deal with circular references is to use lazy initialization, i.e. don't initialize the value when you create your object but when it is first accessed.
If the language you are using has built-in support for lazy values, the solution can look very elegant, e.g. for Scala here: http://stackoverflow.com/questions/7507965/instantiating-immutable-paired-objects. If not, it still works but requires more effort from your side and does not look as "clean".
|
Run into this today:
// for through products foreach ($products as $product) { ... }
Cpt. Obvious strikes again.
|
On September 19 2014 22:51 Manit0u wrote:Run into this today: // for through products foreach ($products as $product) { ... }
Cpt. Obvious strikes again.
Looks like something I would have done in my younger years....or 10 months ago. Might even be my code.
|
On September 19 2014 22:51 Manit0u wrote:Run into this today: // for through products foreach ($products as $product) { ... }
Cpt. Obvious strikes again. I see this every day, dozens of times. Loops, method calls, conditionals, always just stating exactly what the code says. Still better than those that state the opposite of what the code does.
|
Ran into the following today:
User *me; // Actually not me, but you. Where me represents the currently logged in user.
|
how come i dont get awesome comments at work
|
CSS/HTML
if I want text red I can do this:
<red>Text</>
red { color:red; }
Is this bad? Why? Why can't I do this for everything? why even bother with div class= etc etc
|
1. It's not as modular (html shouldn't contain styling information, that should be in css) 2. You're not following the HTML5 spec (only a limited number of html tags are part of the spec)
|
On September 20 2014 14:33 sob3k wrote:CSS/HTML if I want text red I can do this: <red>Text</>
red { color:red; }
Is this bad? Why? Why can't I do this for everything? why even bother with div class= etc etc
Go ahead.
Build a whole web site like that, and then try to do a few changes to it.
Then you know why you don't do it like that 
|
Hello. I have a question regarding LaTeX.
Long story short: I have my CV written in LaTeX but I don't know how it or its compilers work. I don't want to not use LaTeX, I just want the code->pdf shit to work. I have installed Miktex 2.9, and when I do the cmd>dir>cd desktop>xelatex filename (as I've been instructed to do) I get an error. What do I do?
I should add that this has worked before, but I have since formatted my pc.
|
On September 21 2014 02:14 Scalepad wrote:Hello. I have a question regarding LaTeX. Long story short: I have my CV written in LaTeX but I don't know how it or its compilers work. I don't want to not use LaTeX, I just want the code->pdf shit to work. I have installed Miktex 2.9, and when I do the cmd>dir>cd desktop>xelatex filename (as I've been instructed to do) I get an error. What do I do? I should add that this has worked before, but I have since formatted my pc.
Have you tried to read and understand the error message?
It complains that you do not have the font Garamond. So either you can change font or you can install Garamond - which then should solve the problem. If it doesn't, then post again.
|
On September 21 2014 06:29 bangsholt wrote:Show nested quote +On September 21 2014 02:14 Scalepad wrote:Hello. I have a question regarding LaTeX. Long story short: I have my CV written in LaTeX but I don't know how it or its compilers work. I don't want to not use LaTeX, I just want the code->pdf shit to work. I have installed Miktex 2.9, and when I do the cmd>dir>cd desktop>xelatex filename (as I've been instructed to do) I get an error. What do I do? I should add that this has worked before, but I have since formatted my pc. Have you tried to read and understand the error message? It complains that you do not have the font Garamond. So either you can change font or you can install Garamond - which then should solve the problem. If it doesn't, then post again. I have installed the font, but it still gives me the same error. Not sure how to go about changing the font.
+ Show Spoiler +%Font set to Garamand \setmainfont[Ligatures=TeX]{Garamond} %Defines the SC-typeface \newfontinstance\scshape[Letters=SmallCaps, Numbers=Lowercase, Ligatures=TeX]{AGaramond RegularSC} this is the code in question. I get that you (presumably) change the font at the \setmainfont line, but what do I write in the { } brackets on the \newfontinstance\scshape line?
|
On September 21 2014 16:57 Scalepad wrote:Show nested quote +On September 21 2014 06:29 bangsholt wrote:On September 21 2014 02:14 Scalepad wrote:Hello. I have a question regarding LaTeX. Long story short: I have my CV written in LaTeX but I don't know how it or its compilers work. I don't want to not use LaTeX, I just want the code->pdf shit to work. I have installed Miktex 2.9, and when I do the cmd>dir>cd desktop>xelatex filename (as I've been instructed to do) I get an error. What do I do? I should add that this has worked before, but I have since formatted my pc. Have you tried to read and understand the error message? It complains that you do not have the font Garamond. So either you can change font or you can install Garamond - which then should solve the problem. If it doesn't, then post again. I have installed the font, but it still gives me the same error. Not sure how to go about changing the font. + Show Spoiler +%Font set to Garamand \setmainfont[Ligatures=TeX]{Garamond} %Defines the SC-typeface \newfontinstance\scshape[Letters=SmallCaps, Numbers=Lowercase, Ligatures=TeX]{AGaramond RegularSC} this is the code in question. I get that you (presumably) change the font at the \setmainfont line, but what do I write in the { } brackets on the \newfontinstance\scshape line?
What did you install exactly? You might need a \usepackage{whatever} in the header to import whatever you just installed.
Another solution is to change the font to something it can actually find. Is there a reason you're using Garamond?
|
On September 21 2014 23:29 Blitzkrieg0 wrote:Show nested quote +On September 21 2014 16:57 Scalepad wrote:On September 21 2014 06:29 bangsholt wrote:On September 21 2014 02:14 Scalepad wrote:Hello. I have a question regarding LaTeX. Long story short: I have my CV written in LaTeX but I don't know how it or its compilers work. I don't want to not use LaTeX, I just want the code->pdf shit to work. I have installed Miktex 2.9, and when I do the cmd>dir>cd desktop>xelatex filename (as I've been instructed to do) I get an error. What do I do? I should add that this has worked before, but I have since formatted my pc. Have you tried to read and understand the error message? It complains that you do not have the font Garamond. So either you can change font or you can install Garamond - which then should solve the problem. If it doesn't, then post again. I have installed the font, but it still gives me the same error. Not sure how to go about changing the font. + Show Spoiler +%Font set to Garamand \setmainfont[Ligatures=TeX]{Garamond} %Defines the SC-typeface \newfontinstance\scshape[Letters=SmallCaps, Numbers=Lowercase, Ligatures=TeX]{AGaramond RegularSC} this is the code in question. I get that you (presumably) change the font at the \setmainfont line, but what do I write in the { } brackets on the \newfontinstance\scshape line? What did you install exactly? You might need a \usepackage{whatever} in the header to import whatever you just installed. Another solution is to change the font to something it can actually find. Is there a reason you're using Garamond? edit: Never mind, I solved the issue. :DDDDD
|
On September 21 2014 23:46 Scalepad wrote:Show nested quote +On September 21 2014 23:29 Blitzkrieg0 wrote:On September 21 2014 16:57 Scalepad wrote:On September 21 2014 06:29 bangsholt wrote:On September 21 2014 02:14 Scalepad wrote:Hello. I have a question regarding LaTeX. Long story short: I have my CV written in LaTeX but I don't know how it or its compilers work. I don't want to not use LaTeX, I just want the code->pdf shit to work. I have installed Miktex 2.9, and when I do the cmd>dir>cd desktop>xelatex filename (as I've been instructed to do) I get an error. What do I do? I should add that this has worked before, but I have since formatted my pc. Have you tried to read and understand the error message? It complains that you do not have the font Garamond. So either you can change font or you can install Garamond - which then should solve the problem. If it doesn't, then post again. I have installed the font, but it still gives me the same error. Not sure how to go about changing the font. + Show Spoiler +%Font set to Garamand \setmainfont[Ligatures=TeX]{Garamond} %Defines the SC-typeface \newfontinstance\scshape[Letters=SmallCaps, Numbers=Lowercase, Ligatures=TeX]{AGaramond RegularSC} this is the code in question. I get that you (presumably) change the font at the \setmainfont line, but what do I write in the { } brackets on the \newfontinstance\scshape line? What did you install exactly? You might need a \usepackage{whatever} in the header to import whatever you just installed. Another solution is to change the font to something it can actually find. Is there a reason you're using Garamond? edit: Never mind, I solved the issue. :DDDDD
How?
Edit: To clarify; I don't really care too much, since I don't have the problem. Chances are though that some years down the line some random guy on the internet will have the same problem. He googles around and finds this thread "Oh, great someone has found the answer to my problem, but didn't post how to fix it".
Whenever you post a question online and somehow find the answer; please say how you fixed a problem. Some future human will be thankful for that.
|
|
|
|
|
|