« first day (1506 days earlier)      last day (3336 days later) » 
00:00 - 19:0019:00 - 23:00

12:24 AM
@MartinBüttner maybe I completely misunderstood the edit I approved, but I thought it was merely adding in the old byte count that had been dropped somehow
so just a factual edit, not a code edit
 
oh right
never mind then
the other two edits by that user were golfing improvements
so I thought they all were
 
yeah I wouldn't have approved those because I don't know the rules about that
 
no harm done either way ;)
 
12:55 AM
@Optimizer Doesn't CJam have a builtin hypot?
 
1:45 AM
@MartinBüttner I got 27 in Round and Round but then I looked at your answer and it's basically the same thing :/
 
 
3 hours later…
4:35 AM
I had some nice J idea for the Round and Round but I can't compare or cast characters in few chars :(
not sure if APL can do something like that but based on my tryapl.org check it mightnot
 
 
3 hours later…
7:50 AM
@Sp3000 what do you mean ?
@Sp3000 really ? preview ?
 
4rd__{1dmr1dmrmhi-}*//
(the 27's currently sitting deleted in Round and Round)
 
ah, what is hypot ?
 
I assumed it meant sqrt(x^2 + y^2)
 
it seems to
about the string go round..
i think urs deserve to be non deleted answer
 
about earlier discussion for estimating pi, surely estimating the average of sqrt(1-x*x) by taking samples is Monte Carlo?
2
 
7:54 AM
no its not.
 
why not?
 
integral of that equation from 0 to 1 is an exact value of pi/4
as its area under the graph
graph of x^2 + y^2 = 1
 
i'm not talking about doing the integral, but choosing a random collection of 1000 x values, computing sqrt(1-x*x) for each, and taking that average
 
the first quadrant
 
The question's a little vague, but I assumed the OP wanted a Monte Carlo as in "throwing darts at a dartboard and seeing which ones hit", so to speak
 
7:55 AM
@Sp3000 any objections if I use mh ?
 
Why else would I suggest it? :P
 
the OP says "what I have in mind" for that, and i guess it's not clear if that's a restriction or an example
 
@Sp3000 heh
 
Yeah, I think I mentioned somewhere before that you could just generate floats from 0 to 4 and count how many are less than pi. technically it's Monte Carlo...
 
well, yes, but that uses pi directly
 
7:58 AM
(that was before the question added "no pi constants" :P)
 
i think this still fits the spirit: it's a randomized algorithm based on picking many samples that does not use pi and gives an estimate that's near pi with high probability
 
xnor, I agree.
 
in fact, it's a modification of the circle method
where you randomly pick x-coordinates, but average over y-coordinates
 
Besides which, a good question doesn't force you to implement a single algorithm but to meet a spec.
So of the two possible interpretations, I think it's preferable to take the more open one.
 
it is a slightly more boring algorithm, unfortunately
 
8:03 AM
Lot shorter though, nice :P
I'd personally be okay with it, but I just wish the OP clarified better after being asked to clarify once
 
I'm not sure why it was reopened in that ambiguous state.
But I don't think it makes sense to put it through another close-reopen cycle. Better to just take the interpretation which makes it a better question.
 
the average from 0 to 1 of 1/(x*x+1) is pi/4; that might be nicer than sqrt(1-x*x)
 
8:20 AM
That saves about 2 bytes in Python I think. The question just might as well have gotten us to integrate instead XD
 
err, is there a way to map a function like random that takes no arguments?
actually, it wouldn't save chars anyways
 
8:37 AM
Considering help says map(function, sequence[, sequence, ...]) -> list, I don't think so...
 
If you have lambdas you could do map(x->random()), but that's probably too many chars.
 
Yeah, at that point a list comprehension would be shorter...
Too bad you can't do [random()]*1000 or similar though
 
9:23 AM
@PeterTaylor care to comment on the question instead of letting it out here on chat ?
 
9:49 AM
@Sp3000 that is actually pretty clever
well... if the sqrt(1-x^2) approach is valid, I think I can beat GolfScript with Mathematica :D
yep, 30 bytes
@Peter also technically, the credit should be due to PhiNotPi, I think. his earlier message was what xnor was referring to.
@Sp3000 so I've been thinking about transposing with regex... I think it would be even worse than addition... I feel like it's possible with a single replacement in .NET (at least for square input), but I have no idea how to do it in multiple replacements in other flavours
 
@MartinBüttner So... should I undelete or are you going to update your Round and Round answer? Seeing how it's mostly the same anyway
 
nah, undelete it. if something else beating me comes along I might award the bounty to that, but I think yours is different enough
 
And yeah single replacement in .NET does sound possible, if you push the next few non-newline chars in one group, then the newline chars that follow in another group, and work out the corresponding char from that
 
10:05 AM
yep
 
Is that okay format for input ? H "String" W ?
 
why wouldn't it be?
 
dunno
 
Even if it wasn't it beats Martin if I put two @s at the start :D
 
is hypot a trigo function ?
 
10:12 AM
I don't think so
well it's used in trigonometry
but it's just sqrt(x^2+y^2)
if it is I'll have to remove my Mathematica answer :P
 
:D :D :D
ok, i have either 22 or 21 in cjam now
 
the simplest for rectangles would probably be to pad them to a square, then do this, and then remove the padding
 
Well. :P
Nice
 
I think I should be looking for problems outside P
@Optimizer is there no way to shorten your code by using 4/(1+x^2) and skipping the last division?
@Optimizer actually, you can remove the comment on @Peter's answer. I didn't notice that xnor had suggested a different method. so crediting him was actually correct.
 
10:32 AM
are you sure peter is using the 1/(1+x^2) method ?
 
I don't see a sqrt operation
but I do see a division
 
20 bytes
 
you can get the same byte count without a variable
rdU1${4Xdmr_*)/+}*\/
 
i know
its cleaner with a variable though
and I am not a fan of posting all of the same byte similar meaning answers ;)
 
pfff
the reason I keep them is that one of them might still be golfable while another one maybe isn't.
 
11:16 AM
 
the stack snippet is not working for me
 
works for me
 
works in chrome not in firefox
J 61 bytes o.O
 
11:32 AM
@MartinBüttner well J stores the dimensions of the arrays
 
so you can have 5x0 and 0x5 matrices?
 
after all it's an array based language
 
that is pretty convenient
 
yep
when you asked the 0-by-0 matrix representation I checked how J stores arrays internally and there is a specified field for the list of dimensions
 
11:35 AM
On your old matrix rep question: if [] is empty and [[][]] is 0-by-2 you can store anything except N-by-0 where N is positive
which in this case could be enough
 
hi
what terrible tagging offence have I committed ?
I saw some mention of my name
 
@randomra hm, yeah, but then I'd have to check up front if the rectangle is 2 wide or 2 tall and then flip everything if it's the wrong way around, which will cost a lot
@Lembik very terrible
unspeakable, in fact
unthinkable, even
 
the shame.. :(
was it the crime of asking questions that require you to understand undergraduate algorithms?
 
lol no
I just noticed that you're a bit lazy with your tags, and that you tend to use two separate winning-criterion tags
see this for context
 
@MartinBüttner might I ask if you reckon my sandbox post is in a sensible enough state to post to the main site now? I should have time to address any problems that arise today, but probably won't tomorrow
 
11:41 AM
@MartinBüttner ok so can you spell out the lazy part? I mean I feel that if I add >1 tag I get told off
 
@MartinBüttner I promise I didn't see that. But I'm only using hues
 
@MartinBüttner so I tend to reduce the number of tags until I stop being told off :)
 
@Lembik who told you that? o.O one can use up to 5 tags and I believe one should make use of that limit, provided the tags are sensible
@VisualMelon yeah looks good to me
@Calvin'sHobbies no harm done ;)
 
thanks Martin
 
@MartinBüttner ok so actually that first answer is useful. I think I would add code-golf + fastest-code for example and be told off
 
11:43 AM
well yes
those are conflicting
 
@MartinBüttner some people think that winning criteria tags have to be on their own
 
yes, and they should be
 
they don't conflict in my mind
 
but that doesn't mean you can't use some non-challenge-type tags
 
that is your winning criterion has two bases, you put two flags
 
but this is why I put so few tags
ok thanks
 
drat, title too short!
 
yeah, needs 15 characters
@Lembik but you are still using conflicting tags ;) ... says "the code is scored by actual runtime", but says "I made up my own winning criterion"
 
@MartinBüttner OK so those in the know think of them like that. Visitors like me see it as "this question is about writing fast code and about some other challenging aspects of coding too"
so people who want to find challenges that require you make things fast would find it
because that is part of the challenge
it would have been clearer with fastest-code and code-golf.. I interpret it as saying "this challenge is about fast code and short code"
so people who search on either criterion would find it
 
yeah, I guess that's a fair point, but not policy around here. I guess you could ask on meta how people would feel about relaxing the rules regarding challenge type tags
 
11:48 AM
of course we could just have speed-golf as a tag :)
but not until I make a successful and popular speed-golf challenge of course
 
12:07 PM
@VisualMelon is the result for treasure 20?
 
44, have I messed up?
 
maybe I have
ah right
 
(my reference solution agrees with me)
should I publish the reference solution, do you think?
 
I'm not checking yet that the partition is maximally split
 
(then everyone can point and laugh at my inefficient LCM)
 
12:09 PM
ugh, how do I change this...
 
I was thinking about the hue-tracing challenge, and I think it would be interesting to see a program that shows a map of the divergence of the image.
For example, if you load up the swirly hue example, the line will swirl inwards to some points but outwards from others.
 
12:32 PM
awwww, someone decided they stopped liking my mathematica monte carlo answer
 
12:43 PM
meh, I don't think my Mathematica answer can solve Establishments within a minute
 
:( takes my solution 500ms, maybe I should relax the times a bit more
 
Establish took 1.3 seconds, Establishm took 7.3
well my solution is really inefficient, since I first generate a lot more partitions than necessary and then filter
like, all partitions into subsets, not just substrings
I think I can fix this, but it's gonna cost some characters
51 seconds for Establishme
 
hmm, ok, having removed some partition in my solution, it's taking a while longer on Establishments - I don't want people to have to add more characters to make it faster, I just wanted a bound so that people can't be too brutal
 
nah it's okay
my solution was pretty brute force... I just used the shortest combinatorics function that gave me a superset of what I wanted
 
well, it's also hard to time things objectively, and I won't, for example, be able to time yours anyhow, because I don't have Mathematica
 
12:47 PM
the fixed version does Establishments in 1.2 seconds
 
ok, I certainly won't quibble about performance, it just meant as a guide, if you think it's OK then I'll leave it in
I need to attend to a family matter now, so hopefully nothing too exciting happens in the next hour or so
 
@MartinBüttner are you running mathematica on a pi?
 
no
(I do have a Pi though)
I'm not using it at the moment... which kinda makes me sad because it's definitely the best birthday present my girlfriend ever got me, but I don't currently know what to do with it :D
 
sell it on ebay ?
 
1:46 PM
0
A: Sandbox for Proposed Challenges

randomraFinding Collatz-like rules with many loops code-challenge sequence math number This code-challenge is closely related to the code-golf question Analyzing Collatz-like sequences but the goal is quite different here. We define a Collatz-like rule with 3 positive integers: d > 1 divisor m > 1 ...

 
2:16 PM
Here is what Wikipedia says is the definition of Monte Carlo:

"Monte Carlo methods vary, but tend to follow a particular pattern:
Define a domain of possible inputs.
Generate inputs randomly from a probability distribution over the domain.
Perform a deterministic computation on the inputs.
Aggregate the results."
Also, I'm anxiously awaiting January 6th, 2018.
 
2:46 PM
hi, I have a challenge that's been sitting in the sandbox for a pretty long time, it has a +1 and a -1 and I think I addressed all the (two) comments I received so far, last one yesterday; can I post it or should I wait longer?
 
Which challenge is it?
 
@Sp3000 will you accept non-retina regex-only submissions?
 
Does it make it ridiculously easy? :P
(although I don't see why not)
 
I don't think so
but I think I need recursion if I want to solve it in regex
 
2:54 PM
Will be interested to see how you go with that then :)
 
kk... I'll give it a try later
 
Balancing groups would probably work fine too, considering that they are stacks
 
yeah, but it probably still be tricky
I might try that too
 
3:06 PM
@Sp3000 a 00 Pith program is truthy?
 
Yeah, it's just two 0 base commands
 
Just all the test cases I checked had 1 argument output, well except ()
 
"1 argument output"?
 
1 result value (like 1 value in the stack in other languages)
 
I think there's a few other test cases with more than one base command in there, maybe I should add more...
 
3:13 PM
as in 00 there are two values on the stack at the end of execution
 
Oh, right
 
) is zero value on the stack I think
 
Depends how you implement it :P
 
and also the empty program
 
I was going to include the empty program but I decided not to in the end, but it would be truthy if it was in there
 
3:19 PM
as an unmatched ) "does nothing" it's pretty close to the empty program
 
Ahaha true :)
 
@MartinBüttner thanks for clearing my sandbox post, I did that first so I wouldn't forget, then realized I needed a URL... then I forgot ;)
 
@Sp3000 it does
1.mr
 
Did you see the comment following about 1mr?
 
nope, still looking
there seems to be something related 5 hours later
 
3:35 PM
tldr 1dmr
 
same thing
 
Somewhere someone suggested that since 1mr is useless it could be special cased like 1.mr
 
right
 
1md
 
except it would break programs that should generate random ints for various ranges including [0 1)
 
3:38 PM
(Oh, it was Runer112)
 
md for double rand, mr for int rand
 
@Optimizer oh you think 1md should give a random number?
md is divmod
 
not me
 
Runer just made a typo
 
no
 
3:39 PM
I guess you could always just have 1.mr be a different two-char math command, depending on whether the two bytes are worth it
 
Is this really the type of thing we want to encourage?
 
since nobody seems to object, I am going to post my challenge
 
That's one small step from Dilbert randomness.
for which you could just output the constant result value without any computation
 
A verrrrry small step :)
 
that looks like a Herman Cain political speech generator
 
3:48 PM
I made the comment last night because I thought maybe there was something non-obvious going on (it's been a few years since I've messed with C). I didn't expect the post to get two upvotes after pointing it out.
9,9,9,9,9?
You need some Pokemon quotes to go with those nines.
 
It's very wrong to say that that "randomness" has no bias
 
You could say it has no predictable bias, right? If it's truly random.
 
the only thing I know about Pokemon is the South Park parody
 
How in the world have I not seen that episode?
 
it's pretty awesome, especially if you know a few Japanese bad words :p
 
3:53 PM
I can pick out a few. I never got the knack of using them appropriately.
 
@aditsu oh, you are Japanese ?
I always thought ur name is somewhat japanese
 
no I'm not
 
damn
 
and I'm aware my name rhymes with Fujitsu :p
 
baka
I know more about pokemon than south park and I'm not Japanese
 
3:57 PM
"di" isn't a Japanese character anyway :P
 
you can write it with katakana
アディツ
 
Yeah, but that's katakana ;)
 
so happy
 
Sure, but that points out even more that it isn't good Japanese...
 
@Sp3000 where are you from ?
 
3:59 PM
Australia. Background: Chinese. Did Japanese in high school just so I could watch and read things untranslated.
 
so lucky
 
How so?
 
watching animes without the need of constantly looking at subs
@Sp3000 1(310 valid ?
 
Lucky ×
Motivated to study by anime ○
No because the 3 doesn't get enough arguments
 
ok
 
4:03 PM
I'll add that to the cases, it's easier to study than the other one I have there meant to test that
 
4:15 PM
@Geobits :/
@VisualMelon no problem. you could have at least deleted it though ;) (and still can)
 
:\
 
:/
 
/:
 
\:
 
4:22 PM
:<
 
@Geobits u ruined the chain
 
:D
 
^_^
 
kore wa nan desu ka?
 
(⌐■_■)
 
4:26 PM
(Ỏ̷͖͈̞̩͎̻̫̫̜͉̠̫͕̭̭̫̫̹̗̹͈̼̠̖͍͚̥͈̮̼͕̠̤̯̻̥̬̗̼̳̤̳̬̪̹͚̞̼̠͕̼̠̦͚̫͔̯̹͉͉̘͎͕̼̣̝͙̱̟̹̩̟̳̦̭͉̮‌​̖̭̣̣̞̙̗̜̺̭̻̥͚͙̝̦̲̱͉͖͉̰̦͎̫̣̼͎͍̠̮͓̹̹͉̤̰̗̙͕͇͔̱͕̭͈̳̗̭͔̘̖̺̮̜̠͖̘͓̳͕̟̠̱̫̤͓͔̘̰̲͙͍͇̙͎̣̼̗̖͙‌​̯͉̠̟͈͍͕̪͓̝̩̦̖̹̼̠̘̮͚̟͉̺̜͍͓̯̳̱̻͕̣̳͉̻̭̭̱͍̪̩̭̺͕̺̼̥̪͖̦̟͎̻̰̞̖̠̣̦̰̙͕_Ỏ̷͖͈̞̩͎̻̫̫̜͉̠̫͕̭̭̫̫‌​̹̗̹͈̼̠̖͍͚̥͈̮̼͕̠̤̯̻̥̬̗̼̳̤̳̬̪̹͚̞̼̠͕̼̠̦͚̫͔̯̹͉͉̘͎͕̼̣̝͙̱̟̹̩̟̳̦̭͉̮̖̭̣̣̞̙̗̜̺̭̻̥͚͙̝̦̲̱͉͖͉‌​̰̦͎̫̣̼͎͍̠̮͓̹̹͉̤̰̗̙͕͇͔̱͕̭͈̳̗̭͔̘̖̺̮̜̠͖̘͓̳͕̟̠̱̫̤͓͔̘̰̲͙͍͇̙͎̣̼̗̖͙̯͉̠̟͈͍͕̪͓̝̩̦̖̹̼̠̘̮͚̟͉‌​̺̜͍͓̯̳̱̻͕̣̳͉̻̭̭̱͍̪̩̭̺͕̺̼̥̪͖̦̟͎̻̰̞̖̠)
 
Q.E.D. ∎
 
what's up with all the J functions?
 
Stop crying @aditsu . Don't be such a kid
Still crying
 
<That moment when you try out a new pair of earbuds and it feels like you've regained hearing in one ear.>
 
damn, he's still crying
oh stopped.
 
4:37 PM
hi
 
haha
 
why would you do that?
I'm trying to learn Java again, and I found some code with a comment that I don't understand; it's just one line. Anyone here willing to take a look and tell me if this comment is wrong or if I'm being stupid?
 
paste away
 
sure
 
I know a non-negative amount of Java.
 
4:40 PM
public final class Digraph<T> implements Iterable<T> {
/* A map from nodes in the graph to sets of outgoing edges. Each
* set of edges is represented by a map from edges to doubles.
*/
private final Map<T, Set<T>> mGraph = new HashMap<T, Set<T>>();
I don't understand the "Each set of edges..." line
 
this is not really a java thing
 
It pertains to how Set is implemented in the Java Collections? What do you mean?
 
that comment doesn't seem to match the code, or maybe it needs more context
 
It doesn't look like a "set of edges" is a map at all. It looks like it's a set of the same type as the node. Which is weird.
 
I think the comment may just be wrong; maybe it's leftover from before some code was changed
I just wanted to make sure I didn't have some deep misunderstanding
 
4:42 PM
Can you find somewhere it's used and compare?
 
Nope, this is just from a container. I'm gutting it and making my own methods. There's no use case yet
@PhiNotPi I see your comment about MathJax.. I want it too
I put it on my website, but it does introduce a modest amount of extra lag. It's noticeable on bad connections
I also downloaded a local copy, which is pretty amazingly large... it's 54 MB (much more on disk) and 32000 files
 
anyone familiar with the LaTeX class beamer?
 
sort of, Martin
 
"latex beamer" sounds like something in an adult catalog.
 
when you've got "animations", then beamer uses custom PDF page numbers, like 3, 3.1, 3.2, 3.3 for all slides on frame 3
 
4:49 PM
I think I ended up using another similar thing called Prosper for my thesis defense
now I write my presentations using javascript and html
and MathJax
 
it seems that adobe has trouble with that and thinks that all of those slides are now page number 3. which means, I can't print page 3.3 ... I can only print page 3. I need to find a way to either tell beamer to stop doing that (and just give them consecutive numbers, unrelated to the current frame), or adobe to let me print pages with numbers like that...
@EricTressler there are definitely some really sick JS presentations
 
by animations, you mean in-slide transitions?
 
well I just mean frames where stuff pops up over multiple slides
 
@MartinBüttner I switched primarily because I wanted to have actual JS code running real animations. I use a really simple package that is dependent on an outdated version of Jquery, so I'm not really keeping up with the times
 
so no actual animation (hence the quotes)
 
4:52 PM
you're welcome to use mine, if you ever want to: nucularpower.com/talk
I even modified it so it can use one of those clicker/laser pointers
As to your question: sorry, I don't have any idea
 
handout mode should apparently just collapse all the slides into one, but it doesn't seem to do anything
wait, this might have been a caching problem
 
My guess is that handout mode should probably use page N.k for k max
though, if I remember how Beamer works, it's the same thing
 
nah, looks like handout mode does exactly what I'm looking for and just uses page N (with handout mode I don't care about the numbering though, because I can just print the entire handout)
 
are you giving a talk or teaching a class, or what
 
project presentation
 
5:14 PM
@Sp3000 trying Pith in PCRE right now
 
0
Q: Burninate the Martin Gardner tag?

rand al'thorI recently discovered that we have a martin-gardner tag. Martin Gardner was a man who wrote about puzzles (of many different kinds), not a type of puzzle. What use is this tag? Does it tell people anything about the puzzle? He wrote about checkerboard, liars, chess, logic-puzzle, math, and many o...

Uh oh, he wants to burninate Martin
 
I'm only missing parentheses, and I'm at 47 bytes... although I think this parenthesis business will be hardest part
 
Watch out @MartinBüttner, you may be next :P
 
user image
2
@Sp3000 you might want a test case with multiple unmatched ) or (
 
5:29 PM
that reminds me, i want to print out one of those "gathering for gardner" inverted face dragons on cardstock to put in my office
 
0
A: Sandbox for Proposed Challenges

PhiNotPiGerrymander a Map Congratulations! You have been selected as the chairman of your state's redistricting commission. It is your job to propose a division of the state into electoral districts. Your true goal, however, is to make sure that your party wins. To avoid suspicion, your divisions sho...

 
omg that is so real for Americans ^
except in reality, they don't care about "passing a visual inspection" :p
 
that is a great sandbox question
 
5:47 PM
it sounds like an interesting problem, but I'm afraid the best golfing approach will be generating random (or all possible) divisions and testing them for validity and optimality
 
The 4th Congressional District of Illinois includes part of Cook County, and has been represented by Democrat Luis Gutiérrez since January 1993. It was featured by The Economist as one of the most strangely drawn and gerrymandered congressional districts in the country and has been nicknamed "earmuffs" due to its shape. It was created to pack two majority Hispanic parts of Chicago into one district. This district covers two strips running east-west across the city of Chicago, Illinois on the west side continuing into smaller portions of some suburban areas in Cook County, surrounding Illinois'...
 
It could be fastest-code if I create some very large maps.
 
@Sp3000 unmatched ) are driving me mad :D
(is what I said two minutes before I finally figured it out)
Behold the power of recursion
0
A: A Basic Pyth-like Syntax Checker

Martin BüttnerRegex (PCRE), 98 bytes Just managed to avoid a horizontal scrollbar. :) I would have done this in Retina to avoid discussions about where regex is a programming language, but I don't think this will be as short using the .NET flavour. ^((?>0|1(((?(5)!)\))*+(?1))|2(?2){2}|3(?2){3}|4(?2){4}|"[^"\...

 
6:12 PM
honestly, I don't fully understand why this works
3
 
^ story of my life
le me tries to beat regex with cjam
 
yeah it actually doesn't work. it fails to match ()). but I don't understand why it matches some other similar cases.
 
so deleting ?
 
yeah, already did that
I'm not even sure any more if it's possible in PCRE. I need to find a way to determine if I'm inside a certain recursion. I did that by capturing an empty group () and test if that captured anything. but I'm not sure if there's a reliable way to get rid of that group again
I do understand now though why it works sometimes... maybe I can make use of that
later...
 
6:32 PM
reduced 3("4321("301(0)21100"4")"123"00)40"121"31000""01010 to 3(0301(0)00)000)0000
now what ?
 
I have another stupid java question. I want to use an enumerated type for the edges in my graph class. say, RED or BLUE. I want to be able to add an edge with a type RED or BLUE, so I want the enum type to be public. Is the only option really to make a separate file for the enum type?
other than something stupid like having a public method addEdge(..., String type) and check for "type == "RED""
er, .equals
 
does Java not support nested public classes?
something like class Graph{ ... public enum EdgeType { ... } } and then you can select the types from outside with Graph.EdgeType.RED?
 
you can
 
i was trying that earlier with an inner TEST class that just had one member "int A", and I kept getting "variable may not have been instantiated" errors when I tried to declare TEST objects in main
I want to make a graph class that contains two enum classes and an Edge class and a Node class, and I've having trouble. If it's possible to do that, though, I can probably sort out my syntax problems
public class graphTest {
public class TEST {
public int A;
TEST () {
A = 0;
}
}

public static void main(String args[]){
TEST x;
x.A = 5;
}
}
that
produces "error: variable x might not have been initialized" on the line x.A = 5;
 
6:51 PM
@EricTressler that's true, you didn't initialize x; also, variables should generally start with a lowercase letter
 
okay, naming conventions aside. Neither TEST x; nor TEST x = new TEST(); seems to instantiate x
well, the latter complains for other reasons that I recently learned about
 
TEST seems to be an instance inner class, it needs an outer graphTest instance
or you could declare it as static
(and classes have naming conventions too, blah blah)
 
oh. I think I understand. This file should have no main; another file should have a main method, instantiate a graphTest object, and then it will have a TEST member with an A member
 
not necessarily.. you could use TEST as the main class, with "main" in it
if you instantiate a graphTest object, it will not have a TEST member
but you could use the graphTest object to create a TEST object
(if you keep the same kind of declarations as above)
 
okay, I think I'm fundamentally thinking about the logical organization in Java wrong. In C++, I have a Node struct, an Edge struct, a Graph struct that contains nodes and edges, and a main function that instantiates a Graph.
 
00:00 - 19:0019:00 - 23:00

« first day (1506 days earlier)      last day (3336 days later) »