[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 320
Thread images: 42

File: 2000px-Camelia.svg.png (166KB, 2000x1462px) Image search: [Google]
2000px-Camelia.svg.png
166KB, 2000x1462px
Camelia edition

Old thread: >>57224975

So, what are you working on?
>>
>>57233077
Thank you for using an animal image.
>>
Trying to learn tkinter to make a gui to add a username/password functionality to this python application.
>>
https://stackoverflow.com/questions/12953127/what-are-copy-elision-and-return-value-optimization

Only on stackoverflow would they manage to turn a simple question into a 1000 words essay.
>>
>>57233106
That's an insect, clearly.
>>
>>57233124
>insects aren't animals
What a profound observation.
>>
>>57233106
Better than weeaboo shit


>>57233124
kek
>>
Give me O N E reason I should use raw pointers and not
auto variable = make_shared<int>(9);
>>
>>57233111
I was there a few weeks ago, actually, similar reason.

http://www.tkdocs.com/tutorial/
This is probably the best resource I've used for learning how to into Tkinter. I quickly learned that Tkinter is actually ugly as hell but very cross-platform friendly (surprise!). The grid is kind of wonky and as someone who worked with XAML for making a GUI before, XAML is bleeding edge perfection in comparison.
>>
What kind of projects should I make for my portfolio
>>
Anyone understand html and can tell me how to grab the text from a webpage's main body. Or is there no easy way to distinguish between whats the main text and whats the less important stuff without inspecting the page.
>>
>>57233209
document.body.innerText
>>
>>57233178
Speed.
>>
>>57233178
You should use unique_ptr instead of shared_ptr whenever you can. If you can't, you should reconsider your design because shared_ptr is a sledgehammer.
>>
>>57233232
Could you expand upon this a little. Im working in java and Ive been searching the html for key words while its being read in line by line to a string.
>>
Stupid question: How should I document pure virtual functions without being overly redundant?
>>
>>57233256
>speed
Oh yeah. Like I'm really going to worry about a few milliseconds of code.

Besides, "make_shared" can be optimized by the compiler.
>>
>>57233322
>milliseconds
Just use Java.
>>
I just created this disaster.
http://seinfeldpicker.servebeer.com/

What you think?
>>
>>57233306
Your question was extremely vague so that's about all the answer you could expect.

>Im working in java
>searching the html for key words
Start with these next time

>while its being read in line by line to a string
Don't do this, use an HTML parser like https://jsoup.org/
>>
>>57233178
or else i am going to find you and break your teeth.
>>
>So, what are you working on?
Learning Haskell, since last night.

lucky :: (Integral a) => a -> String  
lucky 7 = "LUCKY NUMBER SEVEN!"
lucky x = "Sorry, you're out of luck, pal!"

Can i write this function directly in the interactive interpreter instead of write it in a file an load that? How?
>>
>>57233358
Nice, but images don't work
>>
>>57233322
make_shared might be able to be optimized but shared pointers have a lot of overhead due to the reference counting.
>>
>>57233358
>>57233381
That's weird. I'm not the guy that posted it, but images are working for me.
>>
>>57233363
Well my question is whether theres a way to know whats the main text of a webpage and whats not. Im not looking for an html parser. I just want to know whats the main content. The keywords thing is irrelevant, its just what Im doing right now.
>>
>>57233178

So you can store it on the fucking stack. Also, use references.
>>
>>57233399
odd
>>
File: 1456740495536.jpg (6KB, 250x218px) Image search: [Google]
1456740495536.jpg
6KB, 250x218px
>>57233322
>Like I'm really going to worry about a few milliseconds of code

>>57233355
This.
>>
>>57233371
Thanks.
>>
>>57233396
> due to the reference counting.

Due to thread-safe reference counting, which makes it even slower.
>>
>>57233381
None of the images work for you?
>>
>>57233439
no, apparently it interprets it as '\\' instead of '/'
>>
File: 2016-10-25-203958_795x589_scrot.png (342KB, 795x589px) Image search: [Google]
2016-10-25-203958_795x589_scrot.png
342KB, 795x589px
>So, what are you working on?
Learning OpenGL, trying to make a simple renderer for use in some small scale 3D games.

It'll be sort of stupid but I just want to sort of get a hang of renderer architecture, you know, scene trees, sorting, dynamic vs. static objects, large VBO's vs single VBO per object and the like.
>>
>>57233460
>>57233439
I'm on Firefox on Linux btw
>>
>>57233404
>I just want to know whats the main content
There's no standard place where what you arbitrarily consider the "main" content on a page will be. I suggest taking some time and learning a little HTML if why this is isn't obvious.

What you can do is figure out where the main content on the specific page or related pages is and extract it, and this is where you want to use a parser, because doing any HTML "parsing" beyond the extremely trivial just with Java's built-in String manipulation is going to be painful.
>>
Seinfeld guy
Shouldn't this just be "pictures/"?
>>
File: sicpantibullyprotection.png (626KB, 916x984px) Image search: [Google]
sicpantibullyprotection.png
626KB, 916x984px
/dpt/-chan, daisuki~

Ask your much beloved and highly praised programming literate anything (IAMA).

>>57233358
Sugoi. Javascript or something else?

>>57233318
You should document the expected behavior of the methods.
For an example, see the documentation of the abstract classes from Qt
https://doc.qt.io/qt-5/classes.html
(the classes starting with QAbstract...)

>>57233208
Something for android using React Native.

>>57233077
>So, what are you working on?
r/dailyprogramming and the official dpt discord bot

>>57233077
Thank your for using an anime image.
>>
I am so fucking tired of pajeets that write piece of shit garbage software that starts downloading a bunch of shit outside of the specified fucking installation directory. I TOLD YOU WHERE THE FUCK I WANT THE FILES PERTAINING TO THIS PROGRAM. STAY THE FUCK AWAY FROM MY SSD. GOD DAMN...
How is this shit even legal. There actually should be a law against installing stuff outside of the folders I've OK'd.
>>
>>57233358
>Seasons are integers
>Episodes are decimals
Why?
>>
File: 1420500175412.jpg (438KB, 900x2134px) Image search: [Google]
1420500175412.jpg
438KB, 900x2134px
Would you reach wizard levels if you read and understood all books from listed here + few more EE books?
>>
>>57233737
Two parters
>>
>>57233749
You're not actually a wizard until you can at least apply that knowledge creatively.
>>
how can I print Girl (Boy)
data Sex a = Girl a | Boy deriving (Show, Ord, Eq)

instance Functor Sex where
fmap f (Girl a) = Girl (f a)
fmap f Boy = Boy

instance Applicative Sex where
pure = Girl
Boy <*> _ = Boy
(Girl f) <*> x = fmap f x

instance Monad Sex where
return x = Girl x
Boy >>= f = Boy
Girl x >>= f = f x
fail _ = Boy
>>
>>57233749
i wish clrs had suggested a path through the book suitable for a one-semester course. i know they probably can't chop out a bunch of content given the expectations they've set but it's just unwieldy as is
the writing is also not much fun
>>
>>57233749
where is effective java my man?
>>
>>57233988
let's just throw a python book on there too
>>
>>57233737
That's how the database had it that I scraped from.
Reasoning because they had part 1 and part 2 episodes. Example would be episode 12.1
>>
>>57234036
Couldn't you have at least made it display as N (Part 1) instead of N.0?
>>
>>57234036
>>57234062
Or whatever.
>>
http://pastebin.com/F6wHCHrr

How do I loop the processing to take into account the change of the maxdays variable when the month/year changes?
>>
File: rms-by-simon.png (783KB, 720x879px) Image search: [Google]
rms-by-simon.png
783KB, 720x879px
>A friend once asked me to watch a video with her that she was going to display on her computer using Netflix. I declined, saying that Netflix streaming was such an affront to freedom that I could not be party to its use under any circumstances whatsoever.
how to become this evolved?
>>
I'm a Unity dev trying to do some work in C++ and I'm fucking lost. Anyone willing to help?

All I'm trying to do is create a .dll plugin for my unity project that implements an existing open source library (libyojimbo) but I'm having real trouble trying to get things hooked up. How do I into C++ libraries? (I'll ask with more detail if anyone actually wants to help)
>>
File: jap-12643906348973.jpg (56KB, 490x367px) Image search: [Google]
jap-12643906348973.jpg
56KB, 490x367px
MFW I just realized that C++ {unordered_,}map has no method for creating or updating by the key. Only creating and finding.

Committee must be high level trolls.
>>
>>57234338
>using stl containers
this is where you fucked up
>>
>>57234383
But I like getting errors on two screens.
With actual error somewhere in the middle of the first screen.
>>
>>57233077
How do I program faster? I am doing entry level shit for an internship and it is boring as fuck. I can only do like 3 files and then take a break it's so boring.
>>
File: the_great_debate.jpg (34KB, 719x295px) Image search: [Google]
the_great_debate.jpg
34KB, 719x295px
Which one /dpt/?
>>
>>57234709
xkcd is strictly for faggots
>>
I know C fairly good and the basics of MIPS assembly. I want to learn Java and Android SDK for fun, where do i start? i tried looking at Android Developer website but seemed a bit confusing.
>>
>>57234078
>>57234062
I'll work on fixing that. thanks for the idea
>>
What is the difference between a coder and a proggrammer, and what are some examples of each?
>>
>>57234709
I can't access all Dilbert from Gopherspace
gopher://gopher.floodgap.com/1/fun/xkcd
>>
>>57234799
fuck you
>>
>>57234799
>coder
Any code, could be HTML and CSS
>programmer
Someone who writes actual programs using a programming language
>>
>>57234775
If you already know C, I suggest learning the NDK instead. I don't know what type of apps you want to make, but using SDL2 its pretty easy to setup a native multimedia app.
>>
i'm having a really hard time settling on a language to write scripts in. can you guys just decide for me?
>>
>>57235180
python
>>
>>57235252
>>57235198
didn't want to be a pleb but i guess i'll use it then. any resources you recommend?
>>
Any recommendations on where to learn math with programming? I have been playing with C++ recently, but I don't know much about math, and whenever I look for tutorials they start with shit way over my head.
>>
>>57234839
So using C and making text based waifu sims makes me a proggrammer?
>>
>>57235577
Your waifu sim is a slut
>>
>>57235530
what do you mean? do you mean algebra? or stuff like vectors/matrices? i have a hell professor for my linear algebra class and "linear algebra and its applications" by david lay saved my ass. the only people passing are the ones who already know it, but i'm teaching myself by reading. the book deals with vectors, matrices, etc
>>
>>57235614
Algebra, trigonometry, calculus, differential, stuff like that.
>>
>>57235639
i'd recommend the book i posted for algebra then. plus really helps you understand graphical stuff
>>
>>57235682
Is there any way a poorfag like me could get it for free? I have lost access to my tor library dumb a few years ago, the site is not online anymore, and I wouldn't know where else to look.
>>
>>57235295
Do you know any other languages?
Yes? Learn Python Through Public Data Hacking
https://learnxinyminutes.com/docs/python3/
No? http://www.diveintopython3.net
>>
What's the best editor for LaTeX? Should I just use Vim like for everything else or is there something better?
>>
>>57235759
http://gen.lib.rus.ec/
http://bookzz.org/
>>
>>57235766
emacs
>>
File: theone.jpg (57KB, 400x500px) Image search: [Google]
theone.jpg
57KB, 400x500px
>>57235768
This one?
>>
>>57235815
ye. im not the dirty pirate who told you those websites though
>>
>>57235822
Still, thank you both very much.
>>
>>57235766
gummi is cool
figuring out macros would save you a lot of time though.
>>
>>57235822
>Suggested retail price: $207.60
i'm with the pirates on this one
>>
>>57233178
smart pointers can be kind of heavy sometimes. Especially when if you're using an int.
>>
>>57233404
It's between the body tags, you weirdo.

Also, what that guy up there is offering you is an xml call to the body text, which might be the same but a little weird in regards to java.

What you want to do is just grab everything between <body> and </body>.

The only other tags then are <title> and <head>. `title` is for, duh, the title that goes on the bar at the top. `head` gives you extra header information about the page. Things like languages used in it, utf encoding, script style ??I think??, and possibly other things that could be treated as secondary info just like in pre-processor directives.
>>
Is there a prettier way to code this (python) to find the median of a list of unsorted integers? (i.e: [2,1,5] should return 2; [4,5,5,4] should return 4.5)?? This code works just fine, but my autismdar is telling me its bloated.

def median(sequence):
sequence = sorted(sequence)
if len(sequence)%2 == 0:
sequence = sequence[0:(len(sequence)+2)/2]
seq1 = sequence[-1:len(sequence)]
seq2 = sequence[-2:len(sequence)-1]
seq3 = (seq1[0] + seq2[0]) / 2.0
return seq3
else:
sequence = sequence[0:(len(sequence)+1)/2]
sequence = sequence[-1:len(sequence)]
return sequence[0]

print median([4,5,5,4])
>>
>>57233077

perl on my /g/?

Today was a good day.
>>
>>57236498
You're fucking retarded. He meant that he is far from reaching the real shit you can see in C codebases.
>>
>>57236478
Rate my autism
def med(seq):
seq = sorted(seq)
return (seq[len(seq)/2]+seq[int(len(seq)/2.0-.5)])/2.0
>>
>>57236510
What's the final boss of c programming
>>
>>57236764
When your code gets rated 5 michelin *s.
>>
>>57236764
The IOCCC
>>
>>57236777
Michelin stars only go up to 3
>>
>>57236819
that's what they want you to think
>>
>>57236876
O damn
>>
>>57236885
don't tell me you also believe compilers only go up to -o3
>>
File: BBvOwrv.jpg (183KB, 1700x1275px) Image search: [Google]
BBvOwrv.jpg
183KB, 1700x1275px
I wish I could just compile an Asian girlfriend
>>
>>57237010
just use the -azn flag
>>
>>57237010
iu only wants older men
>>
>>57236764

10+ star, which includes a bunch of stars hidden behind typedefs.
>>
>>57236764
C++
>>
>>57236777
>>57236819
I thought they award a Michelin star if your restaurant is really good. So if you open two restaurants and both get Michelin stars then you're a two Michelin star chef. So a 5 Michelin star chef would need 5 restaurants.
>>
>>57233377
> {: 
let lucky 7 = "blah.."
lucky x = "nigger"
:}
>>
File: 2016-10-25-185411_306x83_scrot.png (2KB, 306x83px) Image search: [Google]
2016-10-25-185411_306x83_scrot.png
2KB, 306x83px
>>57233377
sorry, its actually like this
>>
>>57234383
whats wrong with stl containers?
>>
File: 1477284538461.jpg (13KB, 351x329px) Image search: [Google]
1477284538461.jpg
13KB, 351x329px
>it's a ncurses binding library
>doesn't even have halfdelay()

how the fuck am I supposed to do snake now, huh?
>>
Do any of you know Lua? I'm new to scripting languages, additionally I might be retarded and don't know how to properly include a library.
Anyway, its this one: https://github.com/timn/lua-xmlrpc

Sure, there's a makefile for this exact purpose, but it installs systemwide, and I want to make the script portable, with the required files inside a subdirectory in the same path as the script. There's a test file included with this line:

require "xmlrpc"


How to include it from a subdirectory in the same path?
>>
>>57237235

I'm not an expert in Lua, but I'm going to guess it goes something like

require "path/to/xmlrpc.lua"


Or whatever.
>>
>>57237199
Make your own binding to halfdelay() using the FFI?
>>
>>57237285
That's actually the whole problem: there's no xlmrpc.lua, just a

http.lua
init.lua
server.lua


the makefile just copy these 3 files to "/usr/local/share/lua/5.1/xmlrpc".
>>
>>57237366

So do
require "path/to/xmlrpc"


And assume that your runtime is going to include every .lua file in the directory?
>>
>his language doesn't allow dashes and forward & backward slashes to be in function names

(defun \o/ () nil)
>>
>>57237488

My language treats forward slashes as the beginning and end of regular expression literals, or as a / operator. I don't mind not being able to use it in function names. If I wanted to go weird, I have almost the entire unicode spectrum as valid identifiers, and that includes zalgo text.
>>
File: 2016-10-25_17-21-24.png (36KB, 693x1856px) Image search: [Google]
2016-10-25_17-21-24.png
36KB, 693x1856px
        while (JoyRight_X < 50){//PAUSE UNTIL JOYRIGHT IS  WIGGLED
read_line_in(&x, &y, &z, &t, &b_Up, &b_Down, &b_Left, &b_Right, &JoyLeft_X, &JoyLeft_Y, &JoyRight_X, &JoyRight_Y);
}

do
{
//Get line of input
condition = read_line(&x, &y, &z, &t, &b_Up, &b_Down, &b_Left, &b_Right, &JoyLeft_X, &JoyLeft_Y, &JoyRight_X, &JoyRight_Y);

if (b_Up == 1 && (b_LastUp != b_Up)){//Get toggles
counterT++;
}
b_LastUp = b_Up;
if (b_Right == 1 && (b_LastRight != b_Right)){
counterC++;
}
b_LastRight = b_Right;

//Calculate roll and pitch.
roll_rad = roll(x);
pitch_rad = pitch(y);

//Switch between roll and pitch(up vs. down button)
//Scale your output value
if (counterC % 2){//Use the buttons to set the condition for roll and pitch
if (counterT %2){
scaled_value = scaleRadsForScreen(roll_rad);
}
else if (counterT){
scaled_value = scaleRadsForScreen(pitch_rad);
}
}
else if (counterC){//Use the buttons to set the condition for roll and pitch
if (counterT %2){
scaled_value = scaleJoyForScreen(JoyLeft_X);
}
else if (counterT){
scaled_value = scaleJoyForScreen(JoyLeft_Y);;
}
}

//Output your graph line
graph_line(scaled_value);
fflush(stdout);

} while (!condition); //Modify to stop when left button is pressed
return 0;
}


Working on a moving bar graph using PS4 controller inputs. Output is pic related.
>>
>>57235180
Perl is far superior when it comes to scripts, much more concise and flexible.
>>
ruby is perl for grownups
>>
>>57238117
Au Contraire
>>
>>57237680
Just curious - why are you making this? Just an educational thing or do you plan on using it for something?
>>
>>57233871
>pure = Girl
kek
>>
>>57233871
main = do 
let a = Girl Boy
print a
>>
uint64_t a = 1;

Would this compile on a 32bit machine?
>>
>>57238166
Just educational. May save it for later if I want to tinker with a ps4 controller program later on.
>>
File: how_it_works.png (13KB, 410x211px) Image search: [Google]
how_it_works.png
13KB, 410x211px
>>
File: 1477346082037.jpg (46KB, 625x625px) Image search: [Google]
1477346082037.jpg
46KB, 625x625px
I'm installing mit scheme using the tutorial provided on their page. When I get to installing gdbm i run into the problem that there is no ./configure file there. And when I try to ./configure mhash it throws an error saying "mhash.h not found". Wtf am I supposed to do? I literally just followed their fucking tutorial step by step and it breaks.
>>
>>57236764
making a graphical user interface
>>
who /reinventthewheelforfun/ here?
>>
>>57234709
xkcd is better, because Dilbert is depressing. It's depressing when you end up envying Dilbert's well-functioning office and communicative management...
>>
>>57239065
i reinvent the wheel because i hate using libraries and shit that other people made.
>>
>>57239265
I like to pretend it will impress theoretical future interviewers.
>>
>>57239265
I am the same. Then people ask why i use someone else's compiler, and i don't know what to say.
>>
>>57239065
If i don't reinvent the wheel, i won't understand how the wheel works.
>>
>tfw deciding which javascript library to use for a task
>tfw there are 4,000 of them
>>
>>57239371
>Using javascript
...
>>
Which programming language and/or technology do I learn to get good job? The more *free as in freedom*, it is the better. I also don't have a degree and have heard it's really hard to be employed as C or Java developer without it. So I'm thinking about Python (probably Django).
>>
>>57239364
thank you
>>
>>57239413
Being a prostitute is well paid.
>>
hey yall im trying to pass hidden input along pages of my website. I have it so it logs in and i can echo out the variables in the php code but how do i get it to work in the html part ? what am i doing wrong or not understanding please?
<?php
session_start();

if(isset($_SESSION['id'])){
$id = $_SESSION['id'];
echo $_SESSION['name'];
}
else{
echo "You are not logged in";
}


?>
<br><br><br>

<!doctype html>
<html>
<form>
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
</form>
<form action="logout.php">
<button>logout</button>
</form>
<html>
>>
anyone experienced with batch tasks and ffmpeg?

I'm trying to add a silence to a whole bunch of mp3 files and I'm fumbling it

for /r %%i in (*.mp3) do (
C:\Users\Me\Desktop\-Folder\ffmpeg-20160731-04da20e-win64-static\bin\ffmpeg.exe -i concat:"C:\Users\Me\Desktop\-Folder\ffmpeg-20160731-04da20e-win64-static\bin\silence.mp3"^|"%%i" -c copy -f mp3 "%%i_2s"
move /y "%%i_2s" "%%i"
)


Errors out saying [NULL @ 000000000062c520] Unable to find a suitable output format for '%%i'
%%i: Invalid argument

I don't really know what %%i means but I figured it was some sort of implicit variable (all the examples I could find online used it)

sorry I'm sure this is easy I just have no experience
>>
File: canuck-the-cuck.jpg (109KB, 650x650px) Image search: [Google]
canuck-the-cuck.jpg
109KB, 650x650px
I have been working on a reverse shell in python. I got it to work locally but I want to see if I can get it to work over the Internet. I set up an apache web server but I don't how to, if it's possible, connect to it using sockets. Would I have to buy a server to accomplish what I am trying to do or is their something I am missing?
>>
>>57239483
you have some bizarre stuff here

the first problem is that you are submitting the bottom form and not the top one. they are completely separate. combine them into one
>>
File: pizza-botnet.png (1MB, 1280x720px) Image search: [Google]
pizza-botnet.png
1MB, 1280x720px
i don't understand the halting problem proof
https://www.youtube.com/watch?v=macM_MtS_w4

this guys says you change H to make a machine H+ that loops forever if the input program halts, and then feed it to H+ so it'll loop forever. but H+ isn't the machine that's purported to solve the halting problem, that's H
>>
Program Halts?(Program inputProgram, String inputString){
return true if inputProgram(inputString) halts;
else, return false.
}


Program Deceive(Program inputProgram, String inputString){
loop forever if inputProgram(inputString) halts;
else, return true.
}


Halts?(Deceive, Deceive){
return true if Deceive(Deceive) halts.
//if Deceive(Deceive) halts, it will loop forever due to the definition of Deceive
else, return false.
}


had to write it out in pseudocode to understand, it's like i dream in code
>>
>>57239963
Recursion fucks everything up.

But yeah, I agree, if you give (H+, H+) as inputs to H, then H will solve correctly, so I'd say H+ isn't a solving machine.
>>
File: 1476635931391.jpg (176KB, 693x1153px) Image search: [Google]
1476635931391.jpg
176KB, 693x1153px
>kill yourself
>>
>>57240199
To that I add:
I think the point of the H+ machine isn't to solve the problem, but to prove a paradox, except I think it's wrong: giving (H+, H+) to H+ will never halt, and no, it won't output "no" (making it halt thus making it loop), it will just never output anything, because of infinite recursion, making the paradox not observable.

Basically, if what I just said is true, then passing (H+, H+) as inputs to H outputs "It doesn't halt", so there's no paradox.

prove me wrong
>>
Let's say I have a set of numbers from 1 to 4. I need to reverse them (1 should be 4, 4 should be 1, 3 should be 2, etc.)

Is there any way to do this easily?
>>
>>57240413
put them in to a list, order the list, reverse the list, and put the list into a set
>>
File: mcdouble.jpg (162KB, 1536x1129px) Image search: [Google]
mcdouble.jpg
162KB, 1536x1129px
I want to write my own language. I'm going to start small. Performance is not a big concern. I am very comfortable with C++ and Python.

Should I just write something that interprets text into C++? Would writing it in Python be easier? Is there some other route I should take?

I'm guessing some of you plebs have tried this.
>>
>>57240337
The halting problem is for practical purposes solvable. There is nothing new there.
>>
>>57240529
Implement something that has really simple parsing rules, or else learn a parsing library like YACC. It's common to implement languages in OCaml, a lot of research papers use ML, but it's kind of an obscure language otherwise. If Python has good libraries for parsing then it's probably a fine choice, although I'd personally use something else.
However C++ is essential if you want to design e.g. the garbage collector, or the specific data layout of your PL. A lot of compilers today write the parser in another language and then write the rest of the interpreter in C++ and combine them together, possibly through bootstrapping.
>>
>learning assembly
could you BE more useless?
>>
>>57240510
no that's not a good solution if you just have one number

Anyways I figured you just take the midpoint of the set (2.5 in this case) and do this:

2.5 - 1.5 (desired point is 1.5) = 1.0
2.5 + (2.5 - 1.0) = 4 <-- switched point around axis
>>
>>57239963
Both machines supposedly can solve the halting problem.
>>
>>57233266
I'm interested, can you explain why?
>>
>>57240665
it made sense after i wrote the pseudocode. it contradicts itself in either scenario, whether it's assumed to halt or to not halt
>>
>>57240741
unique_ptr is for when you have single ownership of a resource, and you need to deep copy to have multiple ownership (really multiple single ownerships). This is by far the common case.

shared_ptr is for when you essentially don't know what else might own a given resource. It's got a lot of overhead with its atomic reference counting.

It's kind of silly that the C++ standard library only has these two extremes, IMO, though the type system isn't good enough to do anything in between as safely.
>>
>>57238301

Probably. It would just use two registers.
>>
>>57233256
shared_ptr only has some overhead. unique_ptr has zero overhead and is just as fast as raw pointers.
So that anon should be using unique_ptr's if he wants speed.
>>
>>57233417
>References
>Can't be null
>Can't be changed
Wasted potential desu
Fuck the C++ standards committee.
>>
>>57241214
>null references are a good thing
Anon...
>>
>>57241214
>can't be null
what's the problem?
>>
>>57241214
Just use a pointer?
>>
>>57241244
>>57241263
I see you've just started learning programming, come back when you've got a little more experience.

>Write search function that returns a reference
>Element not found
>Can't return null
>Fucked
If you're about to say that an exception is appropriate to return in that situation (or literally ANY situation), then I propose that you should seriously rethink your programming style.

>>57241280
>J-Just use a pointer
Exactly, references are fucking useless. Why the fuck did the committee introduce them if they're absolutely fucking useless?
>>
File: 1395982158913.png (46KB, 363x364px) Image search: [Google]
1395982158913.png
46KB, 363x364px
>>57241320
Option<&T>
>>
>>57241349
>Rust
Fuck off, we're talking about C++ here.
>>
>>57241360
What about that can't be C++?
>>
>>57241365
The fact that it's not in the standard library.
>>
>>57241373
So?
>>
>>57241380
Are you stupid? How do I use something that doesn't exist?
>>
>>57241962
>print
Separate algorithm from UI.

Also, the if statement is covered in the while loop anyway. Make i start from 0, make (currentFib, lastFib) (nextFib, currentFib) and return currentFib at the end.
>>
Trying to build an uberjar is a pain in the ass, and CMake's UseJava module is fairly broken.
>>
>>57240783
The "best practice" method is to use unique_ptr<> in bindings that own the data, and then you pass raw pointer around using .get() as a temporary

struct big_thing {
int x, y;
};

void calculate_thing (big_thing* bt) {
return bt->x + bt->y;
}

int take_it (std::unique_ptr<big_thing> bt) {
// he's mine now
return bt->x * bt->y;
// gets free'd here
}

int main () {
std::unique_ptr<big_thing> bt(new big_thing());
bt->x = 3; bt->y = 4;

calculate_thing(bt.get());
// i still own 'bt'
take_it(std::move(bt));

if (bt == nullptr)
std::cout << "he will be missed." << std::endl;

return 0;
}


Rust essentially does this exactly, except stricter and safer, and a TINY BIT less overhead (theoretically; the potential overhead is probably optimized out anyways).
>>
How do I get my fibbo sequence to print 0 for f(0) without an if: ?

def fibonacci(N):
lastFib = long(0)
currentFib = long(1)
i = 1
if N == 0:
print(N)
else:
while i < N:
lastFibHold = currentFib
currentFib = lastFib + currentFib
lastFib = lastFibHold
i += 1
print(currentFib)



is what I have right now, but I feel like the if makes it super ugly.

I also did this


def Fibbo(n):
phi = (sqrt(5) + 1)/2.0
fibby = ((phi**n)-((-1)**n)/phi**n)/sqrt(5)
print(int(round(fibby)))



but I don't want to do it that way for two reasons.
1. I just stole binet's formula, so it feels like cheating
2. I feel like doing this with a formula defeats what I'm trying to learn (write better algorithms, even though I understand that this is probably a far more elegant solution)
>>
>>57242124
Matrix multiplication is best fib algorithmfu
def fib(n):
a = np.matrix([[1,1],[0,1])
b = np.identity(2)
while n:
if n % 2:
b *= a
else:
b **= 2
return b[0,1]

You can expand and eliminate the matrix part if you don't care for it, and just keep four variables.
>>
>>57242210
woops, missed a bracket
a = np.matrix([[1,1],[0,1]])
>>
>>57241320
Literally the point of references is to not be null, and to provide extra implicit behavior (because C++ fucking loves implicit behavior) in the case of const references.

Actually, because of references, C++'s semantic rules are actually distinct from C. It's completely different, it only looks exactly the same.
Basically, whenever you refer to a variable (or more technically, an 'lvalue'), you aren't getting that variable's value; you're getting its reference.
So if you have
T x;
the expression
x
will have type 'T&', rather than type 'T' like you have in C. You might wonder, then, how does
T y = (x);

compile, when '(x)' has type 'T&', but the variable binding expects type 'T' (since the types are distinct)?
Just like an implicit cast from
'int' to 'float' in C, C++ casts 'T&' to 'T' by calling T's "copy constructor", defined like
T::T (const T& value) { }

Which initializes 'y' in place using reference to 'x'.
If T is a primitive or trivial type, then the copy constructor is just a dereference and store operation, which is properly inlined.
>>
Any one know why this code takes over 1 minute to run depending on the webpage.
The first line is instant
Url url = new Url(site);
url.openStream();
>>
>>57242248
And you might be wondering, what the fuck is this anon talking about and how is this relevant?
Well, because of reference rules, the following code is valid and meaningful C++ code, while it is invalid C code:
int x, y;
int* ptr = &(cond ? x : y);


The sub-expression (cond ? x : y) has type 'int&', because both 'x' and 'y' are lvalues of type 'int&'; therefore we can apply the & operator to the references and turn them into proper pointers.
In C, 'x' and 'y' immediately evaluate, so the ternary sub-expression has type 'int' and a pointer cannot be obtained.
>>
new to /dpt/, what's the /g/ approved Python IDE?
>>
>>57242301
Emacs. Vim acceptable.
>>
>>57242306
why not gedit
>>
>>57242183
Return lastFib instead of currentFib
>>
>>57239345
>using hardware designed by other people and made by metals that were retrieved from the earth by other people

Explain yourself fraud
>>
>>57242183
see >>57242124
>>
>>57242279
Don't be a faggot, just write
cond ? &x : &y
>>
>>57241320
It makes it easy to create functions for pointers without obviously delegating that a pointer be placed in the parameter list. This helps to avoid an overlap in the `processing` we do mentally. If you want program development to be layered, you can't have pointers making their way into transfer processes as layers. So, for instance, you have a struct that needs to take a value from somewhere, would you rather the program take a pointer, pull out of the function process to assert pointer objectives and then return to the function process as simply a streaming of information, or would you rather pass the address to the next struct using a pointer outside of the function.

I think that makes sense.
>>
>>57241320
>Why the fuck did the committee introduce them if they're absolutely fucking useless?
To make operator overloading work.
>>
Rate my C++ Linked List implementation

http://pastebin.com/hTmYsq3F
Been trying to get this working for a couple days now.

In the add method, inside the else statement on my C# and Java implementations it's just
myLast.myNext = temp;
myLast = temp;


Which works perfectly, but in C++, the only way that it would allow me to do so without getting an access violation for a null pointer was to use the addLast method I made by looping through it and linking the next item at the end. (This is my first time doing templates pls no hate I'm more new-ish to c++)
>>
Trying out Ruby. It's interesting. Managed to easily port over my code for finding any arbitrary permutation of a list.
>>
Jesus, I don't use windows often and thought the random restart thing was surely an over exaggeration but no shit, I was just working on a project in VS to learn win32 APIs and it just.. restarted. I was just browsing MSDN and it suddenly cuts to "restarting" and then "updating". 40 mins in and it's 21% done.
>>
File: topointornottopoint.gif (1MB, 130x188px) Image search: [Google]
topointornottopoint.gif
1MB, 130x188px
>>57242784
lemme make a drawing for you guys
>>
>>57242970
dude, just reschedule

I literally do that every time, set it to 6 am tomorrow.
>>
>A floating point means that the number has, well, a floating decimal point. Its decimal point is at any arbitrarily chosen position. (the position is not RANDOM, just ARBITRARY -- it's chosen based on the needs at that time, but those needs can be anything.)

>Usually, computers have a set number of digits to work with, but can put the point wherever because the math still works out fine. So the difference between 1.2345 and 123.45 is not that big, computationally, in base 10. (computer math is done in base 2 because le ebin binary may mays actually having root in real computation despite most binary converters and the like being totally arbitrary in how they interpret things; computers use base 2 because they only have "On" and "Off" to work with as numbers)

>However, to the user, a moving decimal point can represent a large difference, because the significant figures you can use are necessarily limited.

>Obviously to us, a computer has LOTS of digits to go through, but let's say that we have some fairly small number of them, like 5.

>If I want to calculate physics stuff on a cartesian plane streching out to "Very Far" units on each side in 2d. an object can be at a very precise position near the center, like [1.0082, 2.5598], but if it's far from the center, I star to lose precision. 10 units out, and I can only go to 3 places. 100 units, and I can only go to 2 places, like [650.25, 554.47]. If it's more than 99998 units out, I lose whole individual units as I start to having to define things like 1.0000x10^5 for being at 100000 in any coordinate (but not just htat, but now using much more memory because I have to store "1.0000" and "10" and "5" instead of just one number.)
>>
File: Bn0blPdIQAA4c7n.jpg (30KB, 598x448px) Image search: [Google]
Bn0blPdIQAA4c7n.jpg
30KB, 598x448px
>>57243041
yes
>>
File: this.gif (2MB, 125x100px) Image search: [Google]
this.gif
2MB, 125x100px
>>
>>57237176
you can do top level declarations in the interpreter
you don't need to use let
>>
>>57243030
How? It didn't ask me, I booted up and after a couple of hours I was browsing the web and it cut to the restart screen!
>>
>python
test an algorithm
>java
small personal programs
>c++
large programs shared with others

Can we agree here.
>>
>>57243192
The current (fucking obnoxious) paradigm in Win10 is that you designate "low activity times" (no less than like 8 hours a day) where the computer should feel free to restart when needed.

I shut down my computer every night anyway so I don't run into issues - it just does the updates during the shutdown sequence.
>>
>>57243198
>python
faggots
>java
faggots
>C++
desperation
>>
>>57243198
>python
Just learned what an if statement does.

>java
Just learned what the static keyword does.

>c++
Learned how to program.
>>
>>57243217
C++ is how not to program
>>
>>57243221
C++ is how to program.
>>
File: Stocking.png (497KB, 1920x1080px) Image search: [Google]
Stocking.png
497KB, 1920x1080px
Spent an inordinant amount of time today writing a script to shuffle background wallpapers in Linux Mint 17.2 MATE but shit won't run on startup for some reason. Runs fine from a terminal but adding it to "Startup Applications" fails to run on restart. Anyone have a hunch as to why?

# Script to create a wallpaper slideshow from files in a directory

# Directory Containing Pictures
DIR="/home/bechin/Pictures/Backgrounds/"

# Make sure spaces do not break our script.
IFS=' '

# An array to hold the names of the names of the files to display.
ARRAY=($DIR*.png)

# A counter variable that selects the current picture.
declare -i PIC=0

while true;do

# Command to set Background Image
gsettings set org.mate.background picture-filename ${ARRAY[$PIC]}

# Update the counter to select the next picture.
let "PIC+=1"
let "PIC%=${#ARRAY[@]}"

# Specify how long to wait in seconds before the next wallpaper.
# 3 seconds for testing purposes.
sleep 3

done
>>
File: 1362960884713.png (28KB, 499x322px) Image search: [Google]
1362960884713.png
28KB, 499x322px
>want to try some web backend dev
>rent a bottom tier VPS
>load up Ubuntu, set up my keys, configure firewall
>check the syslog
>hundreds of rejected connection attempts over the past 30 minutes since I created it
>IPs all trace back to weird ass countries all over the globe
>some Chinese IP looks like it's trying to bruteforce its way into a root connection via SSH according to auth.log (good luck, root SSH connections are disabled and would require a RSA key anyways)

Is this normal?
>>
>>57243234
Just put it in your xinit/xdefaults rc. This question would be more suited for fglt
>>
>>57243155
wtf, is that a new feature?
>>
>>57243242
yes
it costs them literally nothing to try
Try fail2ban/just use a different port
>>
>>57243242
Yes, extremely. Any web facing SSH port is going to get raped by botnets. My home server gets about 20 unique IPs showing up in fail2ban.
>>
File: 1476244190598.png (356KB, 599x510px) Image search: [Google]
1476244190598.png
356KB, 599x510px
>>57233732
This all the way. It's basically a fucking virus if it does shit like this.
>>
>>57243242
I once ran a rinky-dink web server out of my home for a personal project. I ended up shutting it down because the logs full of chinese and russian IPs plucked at my paranoia strings. I don't think it was ever compromised, but I was always worried about it. Not again on my home network.
>>
>>57237599
yeah, but have fun using shitty cases like camelcase or underscore

seems to me like
function-whatever
is more elegant than
functionWhatever or
function_whatever
>>
>>57243253
I don't know
But you can do type declarations too
>>
>>57243261
I think most botnets out there usually port scan marginally before they attack, I've generally had other ports get attacked regardless. It's not hard to grep the output of a 3 second nmap in a script.

But yes, fail2ban is very good.
>>
File: top levl repl decl.png (10KB, 700x270px) Image search: [Google]
top levl repl decl.png
10KB, 700x270px
>>57243253
>>57243276
>>
File: 2016-10-26-042749_856x107_scrot.png (19KB, 856x107px) Image search: [Google]
2016-10-26-042749_856x107_scrot.png
19KB, 856x107px
lmao @ java's life
>>
>>57243360
>java2017
>.crossUnicodeEquals(
>>
File: 1465512658573.png (195KB, 508x514px) Image search: [Google]
1465512658573.png
195KB, 508x514px
>love programming
>love studying programming
>hate it as a job
what do
>>
>>57243252
It turns out, I needed the shebang to tell it to use bash. /fglt/ duly noted.
>>
>>57243457
become a sissy escort and do programming as a hobby inbtw cocks
>>
>>57243457
kys anime fag
>>
>>57243457
career in academia
>>
>>57243242
I used to get shitload of romanian IP's except the retard was trying what were like passwords on the username
>>
File: mslain73.jpg (29KB, 450x685px) Image search: [Google]
mslain73.jpg
29KB, 450x685px
>>57243457
Just study something else to do as a job. Music is usually quite popular amongst programmers but also hard to live off of.
>>
>>57243192
strange as it may sound, mine always asks me...it's always on, though. I pay a lot of attention to my quick launch bar also. Did you turn off all the automatic updates?
>>
>>57243492
Yeah I'm pretty sure I did. It's a new install and it hasn't happened before on my desktop, but I don't use Windows pretty much ever anyway. Oh well, it's done now but unfortunately my VS project autosave data was corrupt when I logged in. There might be a registry hack to do or somethin
>>
>>57243491
that is a cute lain
>>
File: mslain108.jpg (178KB, 493x500px) Image search: [Google]
mslain108.jpg
178KB, 493x500px
>>57243527
Indeed it is, I have many more. Have you remembered that you love Lain today?
>>
>>57243470
not cute enough

>>57243471
rude

>>57243472
to be honest this is I've been thinking about lately. Since I really hate work and the thought of working for some capitalist pigs makes me sick, working in academia seems to be the only way.
Sadly, I fucked up by not getting into the national universities, only way back on track seems to be getting a doctorate

>>57243491
maybe sysadmin so I can program in between of fixing printers
>>
>>57233116
What's the problem? It's a good explanation of a non-trivial concept.
>>
File: mslain67.png (402KB, 598x1021px) Image search: [Google]
mslain67.png
402KB, 598x1021px
>>57243558
I'm looking into system administration personally. Unfortunately the profession is being slowly replaced by outsourced remote VM deployment and once-over bash scripts. It's still a good path into network security and consulting, though.
>>
>>57243558
this is the cutest lain
>>
>>57243573
all lains are cute
>>
>>57243261
>>57243264
Got fail2ban set up. Already have 8 banned IPs. Guess I need to set up an IDS so I'll know if someone does gain access somehow. I'm assuming logs and last can't really be trusted if someone did gain root access somehow.
>>
File: 1472935943448.jpg (45KB, 640x480px) Image search: [Google]
1472935943448.jpg
45KB, 640x480px
>>57243576
>>
>>57243457
>hate it as a job
why tho?
>>
>>57243788
because there is no way you'll be doing something you enjoy, or with the tools you like unless you're some godly '''code artisan'' and the company is willing to put up with all your bullshit requests

SOAP, PL/SQP and frontend aren't enjoyable to me
>>
File: YX6ZTJ2.gif (678KB, 480x320px) Image search: [Google]
YX6ZTJ2.gif
678KB, 480x320px
>just got in to programming today
>reading "Jumping in to C++"
>Tried to make a calculator (without looking at how it's done in the book as a personal excercise)
>fucked it up lol
back to the drawing board, i think i've pretty much figured out how it will work, so im gonna go back and re-work this mess.
#include <iostream>

using namespace std;

int main()

{
int user_Valueinput1;
int user_Valueinput2;
char user_Operatorinput;

cout << "Please input your first value ";
cin >> user_Valueinput1;

cout << "Select your operator (+,-,*,/)";
cin >> user_Operatorinput;

cout << "Please input your second value ";
cin >> user_Valueinput2;

cout << user_Valueinput1 << user_Operatorinput << user_Valueinput2;

return 0;
}
>>
oh btw fellas, this just occured to me today for those of you wondering why your pics won't load up well.

If you have noscript on, it could be that this new host delays the secondary calls for media and such to a slower band and prioritizes a full load for the first query set. So like it gives you all you'll need and then says, well you didn't want it. Now you have to wait.
>>
>>57233513
Why not starting from creating your own Cryengine?
>>
does anyone have any book suggestions on game development with modern opengl and c++?
im aware of all of the examples using the new opengl pipeline, but i was wondering more how i should structure my engine code.
>>
>>57243898
well you're just getting the operator as a character
>>
>>57243898
bruv, you're printing out the operator as a text, it won't magically make it into a math operation
You'll either need to write if/else or do switch/case
>>
>>57244064
>>57244045
I know that, that's what im working on
>>
>>57243898
I like your user_ prefix convention.
>>
>>57243041
>tfw 32-bit IEEE 754 floats are less precise than 256-bit fixed-points
>>
I learn better with a more hands-on approach, what are some tutorials I can utilize for learning C++?
>>
Ich habe mir eine GPS Laufuhr gekauft und werde für die eine Pomodoro Software entwickeln.
Ist eine Garmin Forerunner 235
Features sollen sein:
Zeit einstellen
Intervalle
Und die Themen
Dann eine statistische Wertung für die Woche machen.
>>
>>57244128
thanks anon
>>
>>57244264
sprechen sie englisch???
>>
>>57244264
no speaky spanish pablo
>>
Python is really easy and quite powerful
>>
File: 1451553795827.jpg (21KB, 500x500px) Image search: [Google]
1451553795827.jpg
21KB, 500x500px
>>57244615
>>
File: 1476368099116.png (12KB, 225x224px) Image search: [Google]
1476368099116.png
12KB, 225x224px
tfw want to make things to put on my portfolio in haskell but can't think of anything
>>
>>57244679
your own language
>>
>>57244679
create a general AI
>>
File: 6.jpg (69KB, 600x488px) Image search: [Google]
6.jpg
69KB, 600x488px
>>57244725
I am currently learning prolog but I think that would be quite a way away if possible at all
>>
Feed me with Bash scripts, I'm learning Bash scripting now.
>>
>>57244679
>can't think of anything to make
your life is complete
>>
>>57244679
Hmm, decided to make a brainfuck interpreter. Wonder how far i'll get before I quit because I am retarded
>>
I'm trying to be conservative with memory in C#, for a reason unknown to me as well, so I've been remembering the C lessons and how it's prefferable to pass references around instead of the data itself.
But I've also been told that higher level languages like C# and Java already do this automatically for sone larger objects like lists.
How do I tell which objects are sent around as references and which are not?
For example I have a function where I pass 2 lists, a small custom class object and a XmlSchemas object of a larger XML file, so I made that one a reference since I only use it to check values in it and don't change it anywhere.

function(List<>, List<> , ref XmlSchemas  CustomClass)

Should I even bother with shit like this? The function is recursive so it seemed silly passing around the whole XmlSchemas object which is always the same and doesn't change anywhere
>>
zipWith' :: (a -> b -> c) -> [a] -> [b] -> [c]

I find this notation really quite confusing. The fact that -> is right associative doesn't exactly help either.
>>
>>57244846
f x y = x + y

Right associative:
f :: (Num a) => a -> a -> a

Left associative:
f :: (Num a) => a -> (a -> a)
>>
>>57244846
>>57244877

effectively you can just imagine -> as "to"

zipWith :: (a to b to c) to [a] to [b] to [c]
it makes a lot more sense if you think of it this way:

zipWith :: (a -> b -> c) -> ([a] -> [b] -> [c])
So zipWith transforms a binary function into one on lists
>>
>>57244877
What?
>>
File: 1451434814905.png (267B, 400x500px) Image search: [Google]
1451434814905.png
267B, 400x500px
>>57233749
no. they won't prepare you for the mistakes you'll make and they won't teach you how to come up with solutions to those mistakes. practice is what you'd need.
>>
>>57244939
If (->) were left associative, you would need to write
a -> (a -> a)
and for many parameters

a -> (b -> (c -> d))
because otherwise you'd get
((a -> b) -> c) -> d
>>
>>57244934
Yes, i know. It just takes a lot of effort for me to parse that. Especially if i'm to parse it the curried way, which i think i should be doing, or else i'm throwing away a lot of the power of thinking functionally.
And i naturally read
a->b->c
as [(a to b) to c], which is of course wrong.
>>
>>57245006
just think of it this way
everything is a parameter to produce the thing on the right
>>
>>57245093
You mean like refactored to c like pseudocode
f :: a->b->c
would be
c f(a,b)
? That's what LYAH is telling me to do, too.
But it feels wrong somehow. Like cheating. I feel ff i was meant to think of it like that, they would have designed the notation to better reflect that thought pattern.
>>
>>57245306
Sort of. that would actually be
(a,b) -> c
But because of partial application and currying,
(a,b) -> c
is isomorphic (you can change between the two) to
a -> b -> c

So
f :: a -> b -> c
is actually
(b -> c) f (a)

or

c f(a)(b)
>>
>>57245345
I think the latter way is the best way for you to think of it

c f(a)(b)

(notice how it's applied twice)
>>
I really want to use common lisp, but its hard without partial application or functors
among other minor things like the type system
>>
>>57245418
Yeah just start speaking and you should get the hang of it pretty fast.
>>
>>57245434
>speaking
what?
>>
>>57245450
You wanna use lisp right? Just start speaking I'm sure you're already pretty familiar with it.
>>
>>57245450
It was a shitty joke anon made
>>
>>57245462
you asshole
>>
>>57245482
lmao
>>
File: 1466719458577.png (147KB, 358x398px) Image search: [Google]
1466719458577.png
147KB, 358x398px
>when you finally spot the retarded mistake that got you stumped for hours
>starting index should be 3 instead of 2
>>
http://pastebin.com/1pBi7LDg
I have been stuck with this problem for the last 24 hours. I'm supposed to create a village with a certain amount of people (in this case 1000) and the probability that the people here are sick is in this case 0.2.

So that would mean that when you first run this program you would get about 200 sick people which also is the case. After that, it's supposed to gradually for each day lower the amount of sick people by a certain probability, in this case people will get healthy with a probability of 0.2.

Now the loop for doing this seems to work but it doesn't exactly lower the amount with a probability of 0.2, it seems far higher.
An example:
196
35
9
0
196 to 35 is not exactly 0.8 of the original.

I hope I made myself clear. Can you guys see what's wrong with the code? I would very much appreciate the help. I'm still a beginner with Java, have worked with Python before but this is far more difficult.
>>
>>57244805
IIRC java passes primitive types by value and everything else by reference. I could be wrong though.
This is about as much help as i can give you. I know fuck all about C#.
>>
>>57245641
Java passes everything by value. It's just that in case of classes the references themselves are what get passed.

For example, when you write "MyClass b", b itself is a reference to an object.
>>
>>57245606
I haven't really looked at your code, but 196 * 0.2 is close to equalling 35. Are you multiplying by 0.2 when you should be multiplying by 0.8, or, alternatively, multiply by 0.2, then take that amount away from the sick people.
>>
>>57245606
remove
>population.set(i, new Person());
from dayPassesAll

the existing Person updates itself, you don't want to replace it with a new Person that randomly gets sick
>>
>>57245673
Actually it doesn't matter what I set the value (GET_WELL_PROB) to, 0 or 1, I get the same result for some reason so I assume dayPasses maybe is not running.

>>57245691
Are you sure? Because when I remove it, it will just run an infinite loop of the original amount of sick people. There is a big error somewhere in the code but I can't figure it out.
>>
>>57245595
>retarded mistake
>stumped for hours
Try week. I once had an algorithm-breaking bug that had me stumped for three week. I tried every tool i could think of in my debugging arsenal to try to find the problem. I finally found the bug by coincidence, simply by happening to rest my gaze directly on the problem. Turns out i had referenced an 'b' where i should have referenced an 'a'.
Literally changed exactly one character, recompiled, and everything was working flawlessly.
>>
>>57245732
void dayPassesAll() {
for (int i = 0; i < SIZE; i++) {
Person person = population.get(i);
if (person.sick) {
person.dayPasses();
}
}
}
>>
>>57245785
WHOA IT WORKED. THANK YOU SO MUCH!!!

Now I just have to figure what you actually did.
>>
>>57244805
C# is always pass by value. But if you do var obj = new Object(); then the value of obj is a reference to the id of the new object. Basically you're automatically passing "addresses" (the C# equivalent).
>>
>>57245808
no prob

sickperson is useless, it keeps referencing the same old Person inside the dayPassesAll loop when you actually want to iterate through each Person (with population.get(i)) instead
>>
http://www.murphys-laws.com/murphy/murphy-computer.html
>>
>>57245785
>>57245808
>>57245838
Oh okay I think i get it. So in the dayPassesAll loop you declare a person object from the existing population array and check if its instance variable is true, which if it is, you run the dayPasses method and it automatically changes the sick variable if the probability is valid?

It always feels obvious when you know the answer. Once again, thank you so much!
>>
>>57245752
>naming your variables with single letters
You're asking for porblams
>>
>>57245870
f x = x^2 + 2
>>
>>57245855
yeah that's it
>>
>do WebGL code sloppily
>it just werks
>do it carefully
>doesn't
http://pastebin.com/Vrdc88rD
I have no idea why it's not drawing anything.
A quick test with console.log showed it's definitely running the renderBuffer function (and thus the gl.drawArrays inside it) but still nothing happens.
>>
>>57245951
Do you have to flip the buffer or some stupid shit

Does your browser and computer even support webgl
>>
>>57244805
>How do I tell which objects are sent around as references and which are not?
in C#, classes are "reference types" and use reference semantics. structs and primitives are "value types" and use value semantics. so if the object is an instance of a class, it passes by reference (to pass by value or otherwise copy a reference type, use Clone(), provided the type implements the ICloneable interface). if it's an instance of a struct or a primitive/arithmetic type, it passes by value (to pass a value type by reference, use a ref parameter). List<T> is a class and passes by reference. ref is only necessary for passing XmlSchemas/CustomClass by reference if they are structs

>>57245641
this is true. Java does not have user-definable value types, so the only semantic distinction is between primitive types and everything else

>>57245672
>Java passes everything by value
>It's just that in case of classes the references themselves are what get passed
isn't this a contradiction?

>>57245821
>C# is always pass by value
this is not true. see above
>>
>>57245418
Have you tried Chicken?
>>
>>57246003
As I said, I had sloppy WebGL code working earlier, running WebGL version 2 as it is now.
No idea by what you mean about flipping the buffer though.
>>
>>57246076
In normal rendering environments, if you render to a buffer, you then have to flip that buffer so it actually shows up on your screen. This manages framerates, vsync issues, etc besides letting the computer have a chance to do shader effects and shit.
>>
>>57246029
>isn't this a contradiction?
no you're just confusing two different concepts because it's called a reference instead of a pointer
>>
>>57246179
i'm not confusing anything. would you say that a reference in C++ passes by value? because that would be stupid. reference semantics are reference semantics. they have a different name for a reason
>>
>>57246202
this is pass by value:

int foo = 1;

bar(foo);

// no matter what goes on in bar, foo == 1 because we only passed by value


this is pass by reference

int foo = 1;

bar(foo);

// foo might not be 1 because we passed by reference (java doesn't have this, and neither does C, in C you would have to pass a pointer by value)
>>
>>57246202
To comment on the side, arrays are inherently pointerized, so in a way you pass it implicitly by reference, while pointers are otherwise usually explicitly typed.
>>
>>57246232
Error: Foo is not of type *type
>>
>>57246109
Can't say I'm at all familiar with what you're talking about.
Is it something unnecessary but good?
>>
>>57246249
pass by reference in e.g. C++ works as in >>57246232
>>
>>57246284
if you're going to mess with opengl you need to read a lot more than just some babbys first webgl tutorial
>>
>>57246029
>isn't this a contradiction?
>>>57245821 (You)
>>C# is always pass by value
>this is not true. see above
I think you're misunderstanding something here. When you say "value semantics" and "it passes by reference", what's actually happening is that it passes a reference to an instance. This reference is in and of itself a value.

See the answer here for example: http://stackoverflow.com/questions/8708632/passing-objects-by-reference-or-value-in-c-sharp
>>
>>57246232
i fully understand the difference between pass-by-reference and pass-by-value. i'm referring to reference and value semantics in general, which work very differently in C# and C++

>>57246285
pass-by-reference works just fine in C# as well, dependent on the type (class vs. struct/primitive) and presence (or lack) of ref, as opposed to a syntactic token like &
>>
/!\ A L E R T /!\

New thread

>>57246428
>>57246428 >>57246428
>>57246428 >>57246428 >>57246428
>>57246428 >>57246428
>>57246428


/!\ A L E R T /!\
>>
>>57246369
i fully understand this. my point is that it's still *semantically* passing a reference. the implementation is passing *a* value, yes, but a thin wrapper, and far from passing the actual value of the object (similar in many ways to passing a smart pointer - by value obviously - in C++). C# classes are still called reference types, and it's for a reason. the reassignment caveat and ref are just some of the things that distinguish C# reference *semantics* from those of, say, C++
>>
>>57246552
I think it's still an important distinction because of the example I posted in the new thread. >>57246452
>>
>>57245672
Yeah yeah. This in practice amounts to what i said.
>>
>>57245894
f = \numberInteger -> plusTwo (squared numberInteger)
>>
>>57247080
top shig
Thread posts: 320
Thread images: 42


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.