« first day (434 days earlier)      last day (3585 days later) » 

1:01 PM
In my view, any solution to FizzBuzz that doesn't use a simple for loop and System.out.println fails the test. — RemcoGerlich 8 mins ago
Any reason for that?
I think that having an easy option to modify where the output will go is a must to mature programming.
 
Monking! Anyone has ammo?
0
A: Optimize parsing more and moreā€¦ in C#

VDohnal"== false" is not very readable. Use ! instead. If the "object value" is already of desired type (e.g. DateTime), it would be slower to convert it to string and then back again. I would write instead if (value is DateTime) return (DateTime)value; I would not use var result = -999; as a ret...

 
Okay... I must be missing something...
Given this function:
func greatestCommonDenominator(first: Int, second: Int) -> Int {
    return second == 0 ? first : greatestCommonDenominator(second, first % second)
}
I'm getting errors with this code:
let gcd = greatestCommonDenominator(numerator,denominator)
self.numerator /= gcd
self.denominator /= gcd
On the 2nd and 3rd lines, 'Int' is not convertible to '@lvalue Float'
Where is there a float?
 
1:18 PM
does /= do float division?
 
No. Well, it doesn't say explicitly. But it does say explicitly that / does integer division if it's integers
And it says that /= should do whatever / would do then assign
 
what happens if you write self.numerator = self.numerator / gcd?
 
hang on...
it still doesn't work, but it's a different error
cannot assign to 'numerator' in 'self'
self.numerator = self.numerator / gcd
 
0
Q: hi im just wondering if how can i add to input more ternary i build a code using ternary

user49111using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int num1 = 0, num2 = 0, num3 = 0; Console.WriteLine("lowest"); Console.WriteLine("inp...

0
Q: FizzBuzz in Forth

EdwardThere are quite a large number of existing implementatons of FizzBuzz but I awoke this morning in a cold sweat with the terrible revelation that Code Review had no FizzBuzz implementation in Forth! To redress this terrible oversight, I wrote this while sipping my first cup of coffee. : FIZZBUZZ...

 
Oh @Edward... FizzBuzz in Forth
I have no clue what that language even is :D
 
1:24 PM
"CR" is "Count in Reverse" 100 to 1.. right?
 
Now I see
@Nobody I have to use the mutating keyword.
 
IDK, I don't even have a clue which language it is (I assume swift)
 
yea
 
@nhgrif: Does it solve the float problem as well?
 
I solved it
Yea, it solves the float problem as well... which is really odd
 
1:29 PM
It is not a helpful error message in this case
 
Not at all.
Guess that's why it's beta.
 
Maybe you should give them a bug report?
 
Yeah, I will. First, the SO post.
 
(if there isn't already one, I guess people will trip upon this quite often)
 
@Mat'sMug No single clue :D
 
1:33 PM
I tried looking, and if there is one, it's not easily searchable.
 
0
Q: error: 'Int' is not convertible to '@lvalue Float'

nhgrifGiven the following function: func greatestCommonDenominator(first: Int, second: Int) -> Int { return second == 0 ? first : greatestCommonDenominator(second, first % second) } And a struct with the following stuff in it: struct Fraction { var numerator: Int var denominator: Int ...

 
lol CR is carriage return
 
CR is CodeReview.
 
@Mat'sMug:
Cr or CR may refer to: Organizations * Chongryon, North Korea's de facto embassy in Japan * Celtic Reconstructionism * Chiltern Railways * Choose Responsibility * College of the Redwoods * College Republicans * Community of the Resurrection, an Anglican religious order * Congregation of the Resurrection, a Roman Catholic religious order * Consolidated Rail Corporation (Conrail) * Czech Radio * China Railway, or China Railway Corporation, a national corporation in People's Republic of China People * C. Rajagopalachari, Indian politician * Chris Rock, American comedian and actor * Cristian...
I like: China Railway
 
1:40 PM
Celtic Reconstructionism
 
Complete remission
that one is quite fitting
 
lol yeah!
Code Remission
Another system-defined word is CR, which performs a carriage return and line feed at your terminal.
 
Instead of accepting a question you mark it as CR
 
nice
 
1:43 PM
Writing a StackOverflow question should be more like filing an Apple bug report...
 
@Mat'sMug Wow...
 
@skiwi IKR
 
Better write it in Assembly than that
Help wanted with a class name!
 
@skiwi Richard!
 
1:56 PM
You know FizzBuzz... right?
You need to test every object against a certain predicate, and then return a function applied to it
@Nobody That would not really be that descriptive
I'm unsure how to call that map
What it stores is a Map<Predicate<T>, Function<T, R>>
 
I like the obfuscation approach: Get variables' names out of a baby book (telephone book works as well)
 
The goal of the class actually is to replace a switch-case construct
 
@skiwi: Isn't that one step of indirection too much?
 
It gives shorter and more readable code in my opinion
Of course other people need to be able to understand it, which is a concern in practice
 
I think the map is too much. Isn't it intended to be used for associative access?
 
2:02 PM
How do you mean intended for associative access?
This might even get funny with how lambdas are implemented in Java... hmm
 
I map (in my understanding) is an associative container where you access elements by a value like map["Test"] (notation may vary)
In your map the key is a predicate
 
Correct, so a map may not be a correct construct here
 
which returns true for certain values of T
 
Rather a list
 
yes and no
your predicate indicates for which values of T the function is usable
and I assume that these ranges are mutually exclusive or at least one predicate has dominance over the other if both are true
so that you only have to execute one function where the predicate matches
 
2:10 PM
That's the idea, correct
 
so you are actually interested in a map like interface that returns for a given T the function to apply
 
Hmm, I got something
CaseMapping<Integer, String> mapping = new CaseMapping<>();
mapping.add(i -> i % 3 == 0, i -> "Fizz");
mapping.add(i -> i % 5 == 0, i -> "Buzz");
mapping.add(i -> i % 15 == 0, i -> "FizzBuzz");
fizzBuzz(1, 100, mapping).forEach(System.out::println);
But I really need to make every predicate exclusive I think
 
0
Q: Logging a message and the stack trace of caught exceptions

janosUsing Spring's JdbcTemplate to load a specific object by ID if exists, I have this code: Person person = null; try { person = jdbcTemplate.queryForObject(sql, new Object[]{ id }, new PersonMapper()); } catch (EmptyResultDataAccessException e) { LOGGER.warn("Could not find person with id ...

 
currently it is just picking for i % 15 == 0 either of three, in an undefined matter
So I'd need a consistent ordering, or need to make the statements exclusive
 
go for the ordering it is much more intuitive than having to anticipate other predicates that might be added later on to make them exclusive
 
2:13 PM
mapping.add(i -> (i % 3 == 0 && i % 5 != 0), i -> "Fizz");
mapping.add(i -> (i % 3 != 0 && i % 5 == 0), i -> "Buzz");
mapping.add(i -> (i % 3 == 0 && i % 5 == 0), i -> "FizzBuzz");
This is too verbose I assume?
 
IMHO yes
what if you get another case that says every multiple of 13 should be "Bug"
 
Then you're screwed pretty much
 
not when you work with ordering
 
true
But I don't know about ordering either
Is there no way that it would automatically pick the most applicable one?
 
you would have to give them a rating for "most applicable"
 
2:15 PM
Which would most likely need to be manually I think
Would a rating still be better than an implicit ordering?
 
this or it would require much more code
the implicit ordering is a rating
but you could have more general rating systems than an implicit ordering
 
A rating of resp. 3, 5 and 15 seems reasonable
Probably this is now getting really beyond the scope of FizzBuzz.
 
0
Q: command line multipart or single file downloader

sanHi I am looking for code review for this multipart or single file chunk downloader using threading, queues. Everything is working fine, except the display information of the file being downloaded does not work when it comes to second or third url however file does gets downloaded... downloader....

 
I think implicit ordering is better, what would a good method name be?
I think be tempted to go with
first... then, but that would complicate matters more
And then we're back to square one, wondering what such a class/mapping would really add :)
 
@nhgrif Done:
0
Q: FizzBuzz in Objective-C

syb0rgIn my quest for learning Objective-C, I have created the common FizzBuzz code in it. This is due to a suggestion/challenge from @nhgrif to re-implement anything he does in Swift in Objective-C. #import <Foundation/Foundation.h> int main(int argc, const char* argv[]) { @autoreleasepool ...

@nhgrif Submitting a bug report? I did that the other day as well!
 
2:24 PM
@syb0rg @autoreleasepool? That sounds like magic!
 
@skiwi Yeah, some sort of magic that I have no clue if I'm wielding correctly...
 
let a: Int = 10
let b: Int = 5
a /= b
So, that doesn't work in Swift.
 
You cannot do integer division in Swift?
 
No, you can.
a = a / b works.
There's a bug, where it thinks a /= b returns a Float.
 
Can it downcast float to int? (Without checking up front of course)
 
2:27 PM
How do I downcast the result of /=?
a (Int)/= b
 
I meant more if it can do so implicitely
 
I don't think it works like that...
 
In Java for example int i = 1 / 3; gives 0
Hmm now it's some other interesting then
 
Yeah.
 
I don't know if 1 / 3 actually just gives 0, or if it gives 0.33333333f
 
2:29 PM
let c: Int = 4/3
Swift playground says c is 1
 
It may just give 0 and then assignment to integer is trivial
 
2
Q: FizzBuzz in Objective-C

syb0rgIn my quest for learning Objective-C, I have created the common FizzBuzz code in it. This is due to a suggestion/challenge from @nhgrif to re-implement anything he does in Swift in Objective-C. #import <Foundation/Foundation.h> int main(int argc, const char* argv[]) { @autoreleasepool ...

 
So also in Swift integer by integer division always results in an integer?
 
Y'all should upvote that ^^
 
2:30 PM
wait hang on...
Wow, so... the reason this doesn't work
let a: Int = 4
var b: Int = 3
a /= b
Is because let declares it as a const..
but if I change let to var, it works
So it works fine, the problem is the error is unhelpful.
 
That's... interesting
 
'Int' is not convertible to '@lvalue Float'
a /= b
The error should be telling me that you can't change the value of a let variable.
 
Is there any reason one would assume that let means "const"?
 
let is constant
 
Just by reading this, I wouldn't
 
2:33 PM
Only by knowing the language
 
That's one of the first things you learn when reading Apple's Swift docs
 
Yeah
It's page 1 basically.
 
I'm not impressed, but it's fair enough
I don't see the argument of "let" vs "const"
The FizzBuzz challenge really intrigues me though
> Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz"
As human, there is no confusion when writing this down
But when programming, if you put the "three and five" statement last, it fails
 
Well, that's why you don't put a 3 & 5 statement.
 
Or maybe that happens because of the switch-case construct, whereas humans more think in "if"
 
2:37 PM
It happens because the code does not fulfill the requirements
the order of natural language does not necessarily mean the same in programming languages
 
But what does it "mean" in natural language?
Do we really interpredit the " For numbers which are multiples of both three and five print "FizzBuzz"" as last and thus give it more importance over the former statements?
 
No we give it more importance because it is more specialized than the other two
it would also work the other way around
 
So it's really that we interpret the compound statement as a whole, and then assign importance based on context?
 
A can only speak for myself (I am no linguist)
There is a fair amount of ambiguity in the task description and we compensate it with common sense.
Now a programming language/interpreting computer does not have that.
 
So that's the real thing at hand then
 
2:43 PM
If the cases were dependent on each other in a more complex way that we could not grasp then we would have similar problems. In the end it comes down to a not well defined problem: What to do if predicates overlap, which to prioritize ...
 
Could one say that the FizzBuzz problem is not well defined?
 
The problem in itself is but the task description is not.
It leaves room for speculation (although only if you take it by word and disable your common sense)
 
agreed
Computers are just dumb.
Though I think if we are able to understand the whole human brain and manage to implement that in code, that then you can have real Artificial Intelligence.
It's years if not decades off though
 
Don't underestimate the power of exponential growth (no pun intended)
 
I'm to wonder whether the scientific or the resource breakthrough will happen first.
 
2:50 PM
Then again: What use is a simulated human brain when we use computers to get away from it?
 
@Nobody I don't think we are trying to get away from Artificial Intelligence.
 
Thanks for the title @Jamal.
 
I'm afraid if he edits it again, it'll look unclear again. Hopefully he's okay with this.
 
Automation was introduced to avoid repetetive tasks on which humans are bound to fail over time
one of my Profs said that the average human failure rate is 1 per thousand entries
and it gets much worse if the environment does make it easy to make errors
 
I don't think we are using automation as a replacement of human capabilities, we are merely using it as an enhancement.
 
2:55 PM
I hope so too. It's not a very good question, but it looked like he could use some help. I must be feeling generous today.
 
I learned that this is valid Python:
x = [1,2,3,4,5]
for x in x:
    print x
print x
47
Q: Why can I use the same name for iterator and sequence in a Python for loop?

GustavThis is more of a conceptual question. I recently saw a piece of code in Python (it worked in 2.7, and it might also have been run in 2.5 as well) in which a for loop used the same name for both the list that was being iterated over and the item in the list, which strikes me as both bad practice ...

 
@skiwi Usually, the computer takes over the task it does from the human so I would call it a replacement. However, it depends on how broad you define the task.
 
@Nobody That's what happens in practice quite a lot these days, but I'm not sure if it is the best.
A computer would do good to have a few human properties, like a brain.
 
3:13 PM
@ckuhn203 he's a :)
 
By the way, do we even need ?
 
I think that one can BURN :)
 
hm, which license to use for an open source project?
 
some "do-what-you-will-with-it-I-don't-care" license?
 
The OP edited this explanation, but not the code. Could someone confirm if it's really working?
 
3:18 PM
 
@Mat'sMug I'll see what monkey and fish have to say.
 
@Mat'sMug: Well I do care somewhat
 
There's a programmer at my new job, he has a CR account. I'm going to try and get him more involved on the site, he's mostly posting in :)
 
@Mat'sMug Get him on chat!
 
yeah!
 
3:22 PM
Do peple here agree/disagree that it would be good if questions (on SO and on CR and others) would be bumped up the "active questions" page if they get upvoted?
 
hmm
 
that would be many bumps around here
 
Agreed ^
Especially on SO
 
@Mat'sMug
 
[153000 questions with new activity. Click here to refresh]
 
3:23 PM
I misworded it slightly,
It would only hold for questions without an anccepted answer.
 
still many bumps around here ^^
 
Goal would be to draw more attention to a question of which other users think that it deserves an answer
 
lunch time, the kids are hungry - laters!
 
I agree that too many bumps may get well... bumpy
 
the problem is that votes come in packs
if a question gets exposure there are more people voting
which would then mean more exposure ...
 
3:25 PM
@Mat'sMug I just ate breakfast...
 
it also means that questions about more popular languages are more likely to be bumped
 
And it would create some bit of unfairness of unanswered questions vs answered ones... The unanswered variant may possibly get lots of votes in the end
 
 
@CaptainObvious Scan for new questions and post them in chat please.
@CaptainObvious Obey orders.
 
In case someone hasn't seem this zombie, which is still one-away.
 
3:38 PM
pew pew
(me sniping the zombie)
 
Lol. Yeah @Mat'sMug. I added that. I have a feeling he's using a translator too.
A baaaad one.
 
So, did my FizzBuzz suddenly spark others, or was it just pure coincidence? :-)
 
@Jamal I should figure out where I saw it today...
 
I think you started a trend @Jamal. =)
 
My starting point was here
9
Q: Is this FizzBuzz Swift-y?

nhgriffor (var i = 1; i <= 100; ++i) { var fizzBuzz = "" if i % 3 == 0 { fizzBuzz += "Fizz" } if i % 5 == 0 { fizzBuzz += "Buzz" } if fizzBuzz == "" { fizzBuzz += "\(i)" } println(fizzBuzz) } I don't really like comparing strings with ==, bu...

I saw that question
 
3:41 PM
It won't be complete until monkey posts it in C++!
 
So we gotta ask @nhgrif why he made that question ;-)
I'll post it in Java 10 if I have to.
 
Has anyone seem the fizzbuzz?
 
0
Q: Finding if there is a subset that sums to a target value from an array of integers

AnirudhI came across this problem. Problem Statement: Given an array of ints, is it possible to choose a group of some of the ints, beginning at the start index, such that the group sums to the given target? However, with the additional constraint that all 6's must be chosen. gro...

 
@CaptainObvious Wow, 12 minutes? You taking a break this weekend or something, CO?
3
 
@CaptainObvious Someone should be able to improve upon this.
 
3:46 PM
Who wrote captain obvious anyway?
 
@Jamal Doesn't this recurse endlessly if the sets are of equal size?
 
@Nobody Ah, I think you're right.
Go ahead and post that, and I'll upvote it.
 
later, I have to hang up some clothes for drying and if I post a review I want to do more than point this out
 
Alright. I'm sure there's still something else left.
 
@skiwi Because I've begun the journey of teaching myself Swift and I intend to document my progress via CodeReview.
 
3:53 PM
Why FizzBuzz though? Just coindicence, or did you see it osmewhere else on CR recently
 
I probably saw it somewhere else... but step 1 is getting some familiarity with the syntax and such at the most basic level.
Right now I'm working on a Fraction struct.
Which, syb0rg will have to implement as a class.
 
@Jamal It was yours that started it I suppose
 
Right
 
I'm considering learning a new language, but I don't know what at the moment
 
Jamal was talking about fizz buzz in chat actually.
 
3:59 PM
I tend to shy away from languages with immature IDE support
 
@skiwi Objective-C, since we need more ObjC reviewers/questions.
 
And I'm spoiled by the IDEs for Java.
 
Unless you don't have a Mac.
 
@nhgrif I would need to have anything Apple related for it to be worthwhile, which I don't
 
I see.
 
4:00 PM
I'm inclinced towards Ruby, but I'm still unsure
I tried C++ for a bit, but I don't like Visual Studio, even though it may be the best out there
 
@nhgrif Hmm, sounds like fun.
@skiwi C is almost universally supported by every IDE.
 
@syb0rg I've yet to see a C IDE that offers automatic suggestions when you type class names, etc.
I know it's more different with header and source files, etc. And most likely more difficult
 
@skiwi C doesn't have class names ;)
 
0
A: FizzBuzz in Objective-C

nhgrifIf we want to sacrifice readability in favor of performance, we might like something like this: const int fizz = 3; const int buzz = 5; for (int i = 1; i <= 100; ++i) { NSLog(@"%@", i % fizz ? i % buzz ? @"FizzBuzz" : @"Fizz" : i % buzz ? @"Buzz : @(i) ) }

 
If I have an object and use it, then I want to see all possible methods after typign the dot (or how it is in C)
 
4:06 PM
@skiwi No objects in C ;)
 
Programming is about the language as much about the IDE.
@syb0rg I admit that I only know some concepts in C++, and nothing in C.
 
But the good news is, at the end of the day, I encouraged an Objective-C question which illicited plenty of responses. If the questions grow in complexity at a slow pace, soon we'll have many other ObjC literate folks.
3
 
And at this point, we're all overthinking FizzBuzz and have failed the interview question. =;)- — ckuhn203 2 mins ago
2
 
@Nobody Nice!
 
4:18 PM
Thoughts on the color layout and design?
 
hehe... should all these recent questions be tagged with ?
 
That's kind of an awful shade of green/yellow.
The idea of a greenish color is fine, that particular shade just seems off.
 
@nhgrif Do any of these have more appeal? 0to255.com/BADA55
 
nice!
Fable green?
anyone? +50 bounty here:
7
Q: Tracking sports statistics

Platypus MaximusI am designing a new application to track sports statistics with code-first migration. I have the bare minimum POCO setup. The problem is that I am not happy with the design specifically how the players, teams and tournaments are relating to each other. I appreciate any comments and suggestions...

(OP's first question, self-bountied; ends in 4 days)
I didn't address the OP's relationship issues
 
Better? Worse?
 
4:28 PM
hmm I liked BADA55 better
<BADA55>TR</BADA55><0FAB1E>I</0FAB1E><BADA55>T</BADA55><0FAB1E>I</0FAB1E><BADA5‌​5>UM</BADA55>
nah
BADA55 is nice
maybe a little bit too yellow though
 
A little darker
 
78C40F
or go wild with 0EC389
 
Ohh, I like the first one. Especially with the new background color I just choose.
Now it's not just black
 
nice
it does look black to me though
 
4:47 PM
Compare it to the pictures before. It's a very dark gray. I think it makes it pop just a little bit more.
 
oh right, 171D25
charcoal would be nice too
 
What does this use? Google Apps Script?
Oh wait, the OP has already mentioned that. But it still needs a proper language tag.
 

« first day (434 days earlier)      last day (3585 days later) »