« first day (762 days earlier)      last day (4172 days later) » 

7:16 AM
^ Sticky in the head.
 
ylc
Hi, I learned a fast random number generator from stackoverflow.com/questions/1640258/…. This xorshift version works fine, but how can I initialize this like srand() ?
 
7:35 AM
@Telkitty "idoit" - was that a confession ?! <big-grin/>
 
Hi we using this Function:
char *trim(char *temp_string)
{
char *s,
*end;
end = temp_string - 1;
s = end + strlen(temp_string);
while (s != end && *s <= ' ')
*s-- = 0;
return (temp_string);
}
if I understand it correcting it starts at the end of a char array
taking out all characters that are not it the alphabet
Am I right in my understanding?
 
7:52 AM
not quite
 
ok then what have I missed?
 
first, for the general case the function has formal Undefined Behavior, by forming and using the address of a hypothetical index -1
but that doesn't matter much in practice
secondly, the condition *s <= ' ' is probably meant to check for control characters
however, the programmer failed to consider that char is usually signed
so the function will also obliterate e.g. norwegian æ, ø and å
 
anyone here good with recursion?
 
so *s <= ' ' does nothing?
so how can one change it to trim non alphabet numeric characters?
 
8:12 AM
@WilliamYang i'm not good, but perhaps someone else would help if you tell us your question.
 
there is a program I'll have to hand in online at 9
I am not sure if I could do it with recursion
Write a program to generate at random a ticket for Lotto 6-49. This should be six numbers between 1 and 49 (remember, no duplicate numbers!). Store the numbers in a list. The program should also include an option to generate a ticket in which the user can specify some of the six numbers and the program generates the rest. The program should also include an option to generate a ticket in which the user can forbid some of the six numbers.
 
Do we really need to star all 3 of those?
 
so I was thinking the recursive function should loop backwards in an array?
i.e. the sentinel flag would be if (array_index > 0) {call_itself(array_index - 1)} ?
i am a little bit confused
 
Second part is a bit tricky i guess.
You allowed to use STL containers?
 
user1357851
@sehe All genius are weirdos, nowadays I am trying to blend in with the majority - also known as the idiots
 
8:35 AM
lol
 
@WilliamYang not really a job for recursion
 
my prof says recursion... I know C++ but he wants it in python lol
I am still thinking...
 
@Telkitty is this where we're supposed to say "you're doing a good job, mate"?
 
Recursion is awesome thing actually, if you understand it offcourse.
 
i do, but only the very simple stuff like Fibonacci and factorials... lol
I've seen it my whole life but lol... I just feel like, either i am too lazy or I can't grasp it
 
8:38 AM
Land of lisp - read part about recursion, it was really simple to understand whats this all about.
 
hopefully beyond the Fibonacci stuff, today my prof gave us a lecture on towers of hanoi in recursion
 
Main thing about it, is that you have to let it go, free your mind from trying to grasp all this stuff around and concentrate on current momemnt - thats how i wouldve described it.
 
well, your ultimate return value will be some sort of collection, such as an array. You need to pass in a list of banned numbers, and a list of numbers generated so far (perhaps a default argument that generates an empty collection). Randomly generate a number not on either of the lists, add it to the generated numbers list, and then make a further call to this function, passing in the banned numbers list and the new updated generated numbers list. Just don't forget an end condition
which in your case will be once the generated numbers list is so big
 
know it's a tree but lol, the switching roles move_discs(source, dest, spare) got me confused lool
okay i'll try
in C then convert it into python > one language that drove me nuts
 
Use stl containers and move semantics, though don't worry too much if you can't get the move semantics right, it's a performance thing
 
8:42 AM
pastebin.com/yujStFFG - how about that?
 
use liveworkspace.com
 
lol I am trying to keep this as simple and "dumb" as possible since the final product needs to be python as instructed by prof
 
oh yeah, python
 
so that means just vectors, no complex things such as memory allocation, pointers, pass by ref / val, etc (python passes by ref by default I think)
 
well, don't worry about stl and move semantics then :P
 
8:44 AM
I'll try then come back, I wold like to try and write
 
still, what I said should work I think...
 
okay i'll try as well :P
 
yeah, it's basic, randomly generate a number, and it to a list, then pass it into a function that can do the same
Though really, a loop is probably the easiest and best way to do this, but I guess this is an exercise in how to do recursion
 
it's kinda stupid... too
 
any hoops, I have to get to work. I would normally be there already, but damn alarm seems to have not gone off, either that or I just turned it off with out even realising it
 
8:51 AM
wait just a bit sluggish here
what's number_unique()?
ohhh i c
nvm
 
@Telkitty once again (a) you missed my point (b) you contradict yourself by not blending in :) You schould be an actor, I think. Which part do you want to play today?
@thecoshman It is in pure functional languages
 
@WilliamYang Towers of Hanoi is as far away from real world problems as possible :) Why do they use it for recursion? Why not Quicksort or something?
 
it's classic
the code is on my laptop I am now working on my desktop
it's something like 4 lines if I remember > and the prof outlined ALL the function calls that 4 lines generates
 
here are some useful exercises:
(1) write towers of hanoi without recursion, O(1) memory usage
 
it was like move(source, dest, spare) becoming move(dest, source, spare)
 
8:58 AM
(2) write C curve without recursion
 
(3) write dragon curve without recursion
 
@Xeo Are those Howard and Raj?
@WilliamYang Towers of Hanoi is as far away from real world problems as possible :) Why do they use it for recursion? Why not Quicksort or something?
 
Blame Wilfird Laurier University
 
(4) write depth first and breadth first tree searches without recursion. add whatever data structures
and so on
 
8:59 AM
an geeky old lady runs comp-sci department
 
you don't like geeky old ladies?
 
@Aardvark Why do Java and C# call pointers references? :)
 
^ yes lol i know that but I have php projects from day-to-day as well
lol not that... they make like the worst jokes ever
 
some of the coolest people in computer science were geeky old ladies
 
first day of lecture in sept, her joke was > unless your grandma is dead, you should come in and write the exams
 
9:00 AM
@FredOverflow Java doesn't. At least not consistently. Never noticed you get NullPointerExceptions? :)
 
i was like... dafuq that was an insult not a joke
 
@jalf Oh right, the Java people were kinda undecided between pointer and reference :)
 
@jalf uhm, it's both
let me just say, jeff beck certainly knew how to treat a guitar, already back in 1975
 
@WilliamYang sounds like you're the one acting like an old lady... Lighten up ;)
 
lol me how?
 
9:02 AM
Some people don't know when to quit. isocpp.org/forums/…
 
i liked google's sexagecimal literals proposal
 
@FredOverflow The spec is very clear in using "pointer".
 
my god lol sets
 
i think with C++11 we can finally implement it ourselves
almost
 
Why almost?
 
9:08 AM
> An object is a class instance or an array. The reference values (often just references) are pointers to these objects, and a special null reference, which refers to no object.
 
we can't avoid adding quotes
 
haha i am an idiot
don't know how to use set
only know vectors for life
 
@R.MartinhoFernandes any idea where "reference" entered the picture then? Most Java programmers say "reference", not "pointer", as far as I know.
 
Just replace vector with set and push_back with insert ;)
 
9:11 AM
lol I know that
i tried to create it with predefined values and it didn't work
 
Do you have C++11? Then you can just say std::set<int> numbers = {2, 3, 5, 7};
 
@FredOverflow Hmm, I guess they changed that, then.
 
-.- I used [1, 2, 3, 4]
no it doesn't work either
must be initialized by constructor not (...) codeblocks output
 
C++98
 
9:16 AM
int[] fuck = {2, 3, 5, 7};
std::set<int> numbers(fuck, fuck + 4);
 
int numbers_list[] = {2, 3, 5, 7};
std::set<int> numbers(begin(numbers_list), end(numbers_list));
 
@R.MartinhoFernandes There is no begin and end in C++98.
 
There isn't any numbers_list either, yet you introduced one! Notice how it's not std::begin and std::end.
 
what's usergen for???
wait im confused
 
@LucDanton What are you talking about?
@WilliamYang In what context did you stumple upon "usergen"?
 
9:18 AM
@FredOverflow gist.github.com/3959946 Dammit, stupid onebox.
 
@R.MartinhoFernandes Oh, I didn't realize William has this installed.
 
Like everyone else not using C++11, if he has not, he should.
 
The body of number_unique can be reduced to a single statement: return ls.find(number) != ls.end();
 
ohhhhh
i think i might've got it
 
9:20 AM
If your answer to 'What's your favourite 12 year-old Port?' is 'USB 2.0', you need to get out more.
 
What else would a Port be? A wine?
 
if(usergen.size() > 0) {
    // insert at end of usergen
    array.insert(usergen.back());
    usergen.pop_back();
}
so this here
 
The comment is wrong. That's why I hate trivial comments.
 
is this the idea that the function will populate the final array to its desired length with
 
Hey, Germans, what does TOM stand for?
 
9:22 AM
It does not insert at the end of usergen, it moves the last element from usergen into the array.
@R.MartinhoFernandes More context please.
 
well not desired length, but probably one or more of the undesired numbers
then pop it off later?
oh lol
it's strangely intuitive
 
It would be intuitive without the misleading comment.
 
@FredOverflow It's on an email subject, as a prefix, like "TOM: Essen gibt es 13 Uhr."
 
Never seen it like that. Might be someone named Tom, or it might stand for tomorrow? Really no idea.
 
yes ^
 
9:25 AM
@FredOverflow Nope, definitely not someone named Tom. This is on lots of e-mails, and most of them are general announcements sent for everyone. I guess I'll just ask someone here.
 
@R.MartinhoFernandes Googling "re fwd tom" doesn't yield anything interesting. Might be something special in your company.
 
what's with sets and vectors....
i can't use setSomething[1]
 
The elements of a set don't have an index, just like sets in mathematics.
 
Why do you think you want an index into a set?
 
9:28 AM
then how on earth do I get the element at index... lol
that's possible with vectors
 
WHY DO YOU WANT TO INDEX?
 
is vectors a subclass of set???
 
@WilliamYang a vector is not a set ;)
what are you trying to do
 
wat?
 
to loop thru and read the contents???
 
9:29 AM
@WilliamYang nope
 
for(int i = 0; i < winning.size(); i++){
cout << winning[i] << endl;
}
 
A set can tell you "is this value in the set?", and that's it basically
 
for (std::set<int>::const_iterator it = my_set.begin(); it != my_set.end(); ++it)
{
    std::cout << *it << '\n';
}
 
facepalm couldve been sooo much easier if it were vectors
sets too professional
 
for(auto it : setcont) bla_bla(*it);
 
9:30 AM
@WilliamYang you haven't told us what you are trying to do. Why do you want to loop through the set, why do you want to index anything?
 
@Ivan0x32 He does not have C++11.
 
user1357851
@sehe Umm ... obedient french maid? >_<
 
user1357851
 
Are you trying to find out of the value x is in the set? Or are you trying to traverse every element of the set?
 
@WilliamYang Iterators are more generic than indexes. You'll learn to love them eventually.
 
9:30 AM
ok ok for(Bla_bla_set_iterator it = setCnt.being; it != setCnt.End(); it++) bla_bla(*it);
 
You could also say std::for_each(my_set.begin(), my_set.end(), bla_bla);
 
@Ivan0x32 Range-for operates on elements, not iterators.
 
forgot that
 
Oooh, I have been through this yesterday. My opinion is that looping across a range with indices is for primitive cavemen.
 
@R.MartinhoFernandes unless u have to loop trough pairs of elements though :)
 
9:33 AM
@WilliamYang By the way, your vector indexing code is broken. You need to use std::vector<int>::size_type instead of int or you'll get errors for very large vectors. Also, every sane C++ compiler will warn you about signed/unsigned comparison.
 
im changing everything to vectors
 
@Telkitty lol
 
@Ivan0x32 Can also be done with two iterators.
 
and this has to be translated into python too
so i can't use sets
 
@WilliamYang Deciding between a vector and a set should not be done based on whether they can be traversed over with indexes.
Python doesn't have sets?
 
9:34 AM
uh, python has sets too, doesn't it? And if you actually need set semantics, then changing it to vectors will break your code
 
OMG, there's so much wrong here.
 
it does, my prof wants it simple...
 
Here's a tip: design your code based on what behavior you need. Not on what you can do without having to learn anything
 
room topic changed to Lounge<C++>: Please don't come in. We are overflowing with wrongness. [beep] [c++] [c++11] [c++-faq]
 
lol I am trying to dissect the code the guy gave me above
 
9:36 AM
You seem to believe that the difference between a set and a vector is basically that "sets are harder to use". They are different things, they do different things. A vector can contain duplication, and has no easy way to tell you if a value is contained in it or not. A set does not contain duplicates, and is designed so you can efficiently ask it whether any specific value is contained in it
You should try using the one that describes what you need
Good luck telling your professor that "I chose the solution that didn't require me to learn anything. It doesn't work, but at least I avoided any actual education or learning"
 
You guys use execptions?
 
Sets are very useful if you know how to use them
 
damn okay no sets, just vectors
 
@Ivan0x32 No, I prefer Optional Types and the Either Monad over exceptions.
 
9:37 AM
@Ivan0x32 Ogonek throws by default if you feed it bad data.
 
i am wondering why this doesn't work
bool number_unique(vector<int> &v, int x){

bool bar = find(v.begin(), v.end(), x) != v.end();

if(bar){
return false;
} else {
return true;
}
}
 
@WilliamYang I am wondering what "doesn't work" means.
 
If you wanted to determine if a deck of cards had exactly 52 cards of each suit and rank, that task would become far more difficult without a set
 
@R.MartinhoFernandes whats Ogonek?
 
Or map for that matter I suppose
 
9:38 AM
it needs to be in python... lol
 
@WilliamYang I'm wondering why you're making life so needlessly hard for yourself
@WilliamYang have you considered maybe.... writing it in python?
Maybe even using Python's set data structure?
 
the python room is nowhere to be found
 
@Ivan0x32 A library of mine.
 
no i meant... stackoverflow python chat
 
9:39 AM
@WilliamYang Do you have to be in a special python room in order to write python?
 
it's like... empty
 
@R.MartinhoFernandes Say, do you have a modus operandi for benchmarking compile-time heavy features? I'm getting kinda annoyed that I have neat-ish features (e.g. Phoenix-style polymorphic functors on the fly) that I don't know the cost of (or even in what terms to express that cost).
 
LMAO
 
no, that is why i am here
omg lololol
 
A recent unit test takes ~10s to compile, which is not usual.
 
9:40 AM
are you seriously telling us that you are writing your homework in the wrong language because you need to be in a chat room with others who can tell you what to write?
 
@LucDanton No :( I have asked you this same thing some months ago. :(
 
dude
i am trying to have a grasp on recursion
i want the idea
not the language
 
Just ask on stackoverflow, and the Python guys will help you within five minutes.
 
Grow up and take responsibility for your code. It's your code, your homework, your education and your programming skills. If you have a question about your python code, ask it on stackoverflow.
 
9:41 AM
@WilliamYang Recursion? Where is the recursion in your code?
 
then that would be like... pasting code
omg lol this guy... never read chat history
 
This room isn't for C++ questions either. It's for hanging out and slacking! If you have programming questions, post them on stackoverflow. That's what it's for
 
@FredOverflow Did I mention the wrongness is overflowing?
 
@WilliamYang You want to know what recursion is? First ask me what recursion is, then we'll talk about recursion.
 
You will know what recursion is once you know what recursion is.
 
9:42 AM
i know what recursion is...
god people these days
 
1 min ago, by William Yang
i am trying to have a grasp on recursion
 
Recursion example: You learn a language by learning one feature, and then learning the rest of the language. Stop when there are no more features to learn.
 
Could have fooled me
 
@R.MartinhoFernandes Well fuck. It's just that so much of the convenient stuff only has an out-of-line counterpart (i.e. anytime a function template returns something really), that writing a sensible comparison takes so much time to write.
 
not 1 minago more like 30 mins ago
 
9:43 AM
@LucDanton But since I never got annoyed enough by compilation times, I did not put much thought into it and moved on. I filed the issue under "will solve when it becomes a problem".
 
I wasn't trying to be snarky. If you googled recursion, google will say "did you mean recursion?"
 
@Mysticial He lies not.
 
@FredOverflow In the case of C++, never?
 
@R.MartinhoFernandes I suppose I do the same. I'm mentioning it because I was surprised that a 330-line unit test so easily ballooned up to 10s of compilation.
 
@R.MartinhoFernandes Right. Also, learning just the features probably isn't enough. You also need to learn best practices.
 
9:44 AM
@WilliamYang well, we're not the ones who decide to sabotage our own homework just so that we can ask questions in a chat room which isn't actually meant for answering questions. We're here for goofing around, and we never tried to hide that fact. Stackoverflow is a website dedicated to not goofing around, to actually answering real programming questions. And yet you refuse to use it to help with your homework woes... And you complain of other people "these days"?
 
how do i numbers
3
 
lol, it increased fivefold.
 
I can't count!
 
@sehe perhaps, but doing a simple loop in C++ is an easy way to go for this problem
 
You know somewhere in google's search engine code, there's a line that reads: "if ((alternativeResults > 1000 && results < 1000) || input == "recursion") {
 
9:47 AM
@thecoshman right. Apply for a job at IBM? True but irrelevant. Correct but unusable. Superior but out of reach!
 
@sehe Ah IBM: it may be slow, but it's hard to use.
 
@Neil :)
 
oh dear... I left that prime number visualisation thing running over night...
lazy thing gives up eventually :P
 
> For various reasons, the original animation topped out at 10,000. Use the unlimited version to enter the device-wedging, battery-burning beyond!
 
9:50 AM
@thecoshman what was last number?
Probably something like 32k, just understood.
 
@R.MartinhoFernandes Say, have you ever felt like you missed Boost.MPL's feature of defining metafunctions on the fly, e.g. is_same<_1, int>? (Even assuming you've made use of MPL here...)
 
@LucDanton Not really, no.
It might have come handy once or twice, but that was it.
@thecoshman What the heck is that?
 
I'm finding myself writing a lot of throwaway aliases to pass to higher-order metafunctions. Could be that I've been dealing with tuples (and hence type lists) a lot recently.
 
@R.MartinhoFernandes -_- never you mind...
 
9:55 AM
I dunno, I might just attempt to write a meta::Apply<Foo, Args...> that does some bind-like remapping. If it's simple enough, I'd like to think that means I have obsoleted Boost.MPL.
 
@thecoshman I think you're off by an order of magnitude.
 
@FredOverflow It's just a typo, don't worry. It's like his signature move.
 
@FredOverflow ffs
@R.MartinhoFernandes ¬_¬
 
sbi
@R.MartinhoFernandes In German, "TOM" means "title-only message". :-/ /cc @FredOverflow
 
9:58 AM
Oh.
 
@sbi How is that German lol.
 
sbi
@FredOverflow That isn't German, but I do know that company's customs.
In fact, I will have archived the email that introduced the custom to the company. I am anal about archiving emails.
 

« first day (762 days earlier)      last day (4172 days later) »