[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: 322
Thread images: 34

File: andrei.jpg (18KB, 200x256px) Image search: [Google]
andrei.jpg
18KB, 200x256px
Andrei Alexandrescu please give me the D edition

What are you working on my dudes?
>>
File: bjarne.png (91KB, 136x275px) Image search: [Google]
bjarne.png
91KB, 136x275px
Thank you for using an anime iamge
>>
Should I learn and practice Go as a check box on my CV or does Go make you look like a novice to HR, kind of like listing PHP?
I know most other major languages.
>>
>>57928187
Go is a meme lang
>>
>>57928199
Will it hurt or help my CV?

I mean, for the same reason why I would never include PHP in job applications.
>>
>>57928213
HR lads will probably consider it a "literally who" lang at best, a complete worthless joke of a lang at worst
>>
>>57928213
I doubt HR would knock you down for knowing an extra language. Throw it on there
>>
File: i got myself an anime!.jpg (204KB, 440x574px) Image search: [Google]
i got myself an anime!.jpg
204KB, 440x574px
How do you feel about multiple layers of indirection?
to[bot[i].send[j].addr].store[to[bot[i].send[j].addr].idx++]
>>
>>57928261
>not putting to[bot[i].send[j].addr] into a variable
For shame
>>
>>57928213
HR are a bunch of people who don't know what they want. Go with Go if you want, but don't expect they know what Go is.
>>
Learning scala I just stumbled with this:
scala> abstract class Shape {
| def getArea():Int // subclass should define this
| }
defined class Shape

scala> class Circle(r: Int) extends Shape {
| def getArea():Int = { r * r * 3 }
| }
defined class Circle

What's the point of abstract class if I will repeat everything again in the real class?
>>
>>57928371
Isn't it necessary to make it part of Shape's spec?
>>
>>57928371
>What's the point of abstract class if I will repeat everything again in the real class?
You won't always necessarily, with abstract classes you can define some functions and leave others unimplemented
>>
File: 106950490.png (55KB, 217x190px) Image search: [Google]
106950490.png
55KB, 217x190px
>>57926495
I know you probably won't see this post, but I want to thank you again, anon. I actually fixed the problem using Spy++.
In the end it wasn't a bug, but a weird Windows behavior because of slide show wallpapers that changed the parent window of the SHELLDLL_DefView from Progman to a window full of 'clones' called WorkerW.

Anyway, god bless you, anon.
>>
>>57928395
just to understand, can I do something like this?
abstract class Shape {
def getArea():Int = 3
}

class Circle(r:Int) extends Shape {
val radius = r
}

(I know the area doesn't make sense, but it's just an example)
>>
>>57928446
I'm not familiar with Scala, but I'm assuming getArea() always returns 3?
That should work then, yes.
>>
>>57928484
I just installed scala (yes, I didn't before jumping into it, bacause I'm evaluating also clojure syntax). Actually I understood what you mean: I can't implement the functions in the abstract type, only in the derived class, but I don't need to implement everything.
It's dumb imo, but I will deal with it, after all, is oop.
>>
I'm planning on building an Android app. Should I go with Java on the serverside or with Python? Been learning both, have some Java server code laying around somewhere too.

The app itself is going to be java.
>>
Hey guys, I know this is going to be a really basic question for you but google isn't bringing me anything relevant, I got this assignment and the first part is to implement a templated Array class header's member functions but it says to do so in another header file? How is that possible? They got Array.h and Array.hpp what's the point of that?
>>
>>57928504
>I can't implement the functions in the abstract type, only in the derived class, but I don't need to implement everything.
If you mean you don't have to implement everything in the abstract class, that's correct
To reiterate, with the abstract class itself, you can have a mix of implemented and unimplemented functions within it. In order to use the abstract class then, you must inherit from it with a subclass and define any unimplemented functions.
>>
Would this be the right thread to ask about unity?
It's confusing me to be honest
>>
>>57928619
>>>/vg/agdg
>>
>>57928411
No problem dude.
>>
How do I properly scale down images in WPF in C#? If I set smaller size, the picture becomes grainy. How do I avoid it and make a proper thumbnail at the specified size out of it?
>>
>>57928690
Set the bitmap scaling mode to something else.
https://msdn.microsoft.com/en-us/library/system.windows.media.bitmapscalingmode(v=vs.110).aspx
You can do it via the property RenderOptions.BitmapScalingMode in xaml.
Fant is the highest quality. Probably no real reason not to pick it usually.
>>
>>57928371
abandon that disgusting shitstain of a language and kill it with fire
>>
>>57928725
Thanks!
>>
>>57928776
Just try to Google next time first. It's really easy to find.
>>
printf is probably the only positive contribution C has made
>>
File: xd intensifies.gif (237KB, 255x162px) Image search: [Google]
xd intensifies.gif
237KB, 255x162px
>>57928895
LE TRUE STORY XD
>>
>>57928901
Ironically shitposting is still shitposting
reported
>>
>>57928895
How did people print formatted strings before printf?
>>
>>57928984
one part at a time
>>
>>57928919
>>57928895
and his shitposting is not shitposting?
>>
>>57928997
That's not shitposting you silly retard
It's a completely decent point to discuss in a completely on topic fashion

Not everything you disagree with is shitposting
>>
>>57928213
>not tailoring your CV to the position to which you apply
sad!
>>
>>57928993
it still works like that deep down tbqh famalam
>>
>>57929090
obviously
>>
>>57929105
just wanted to point that out
even in /dpt/ (or especially) some people think abstraction is magic and everything just happens in one line of code
>>
>>57929122
in bash this is just
myProgram
>>
>>57929122
>even in /dpt/
/dpt/ is pajeet tier that thinks that embracing functional programming will make them better
>>
>>57929122
Sometimes I think people who obsess over one liners are like that. But usually I can assume they know better.
>>
>>57929144
wow so efficient
how did you do that
>>
>>57929149
t. poo in the loo
>>
>>57929170
I don't think he's complimenting functional programming anon.
>>
>>57929225
>reading comprehension
>/g/
>>
Solving https://www.reddit.com/r/dailyprogrammer/comments/5h40ml/20161207_challenge_294_intermediate_rack/ in Rust.
>>
>>57929490
Well. If he's apoo he's clearly pajeet tier. Which would imply he's high tier which would imply functional programming is a godsend.

But the interpretation i take is that pajeet tier is low tier and this guy considers himself above it. Calling him apoo then makes no sense. Apoo wouldn't insult pajeets.

Hypothetically you could be saying the equivalent of 'this'. Meaning you agree with his assessment. But that's far fetched and went way over my head them.
>>
Who /kotlin/ here
>>
So in C++ you can create an object of a class with the default constructor like
Thing thing();

But how do you create an object array of a class and initialize each member of the array with the default constructor?
>>
Anyone have any suggestions for machine learning or pattern recognition books?
>>
>>57929579
elements of statistical learning, but is a bit hard
>>
File: 1451709195256.jpg (12KB, 255x186px) Image search: [Google]
1451709195256.jpg
12KB, 255x186px
Have you let garbage collection in to your life yet anon?
>>
>>57929571
Thing thing[arraysize];

Calls default constructor for all elements.
>>
File: 1475902555180.png (3KB, 392x20px) Image search: [Google]
1475902555180.png
3KB, 392x20px
>>
>>57929660
I'm not retarded.
>>
>>57929726
Wrong.
>>
>>57928261
Read up on the Law of Demeter. (If this is your code, kys)

http://wiki.c2.com/?LawOfDemeter

This is my Advent of Code day 3, it works. Have any suggestions?

#lang racket

(require (prefix-in c: data/collection))

(define (read-lengths ip)
(define line (read-line ip))
(if (eof-object? line)
eof
(map string->number (string-split line #px"[[:blank:]]+"))))

(define (triangle? ls)
(define sorted (reverse (sort ls <)))
(> (+ (cadr sorted) (caddr sorted))
(car sorted)))

(module+ test
(require rackunit)
(define s #<<EOF
883 357 185
572 189 424
842 206 272

EOF
)
(define ls
'((883 357 185)
(572 189 424)
(842 206 272)))
(check-false (triangle? '(5 25 10)))
(check-equal? (port->list read-lengths (open-input-string s)) ls))

(module+ main
(define ls (port->list read-lengths))
(displayln (format "Number of valid triangles (part 1): ~a" (length (filter triangle? ls))))
(define ls1 (sequence->list (c:map sequence->list (c:chunk* 3 ls))))
(define ls-part2 (append* (map (λ (e)
(apply (curry map list) e))
ls1)))
(displayln (format "Number of valid triangles (part 2): ~a"
(length (filter triangle? ls-part2)))))
>>
>>57929763
Fuck me, turns out I was wrong. I looked at the assembly and it actually does loop through and initialize all the elements.
Strange, I remember differently for some reason.
>>
File: 1457.gif (174KB, 500x375px) Image search: [Google]
1457.gif
174KB, 500x375px
>>57929801
Christ, 4chan does a terrible job syntax highlighting s-expression languages.
>>
>>57929763
>>57929820
RAII nigger.
>>
File: .jpg (29KB, 427x285px) Image search: [Google]
.jpg
29KB, 427x285px
>MMDCCLXIX AUC
>their programming language doesn't give solutions to problems on its own
>they spoonfeed computers with code

fizzbuzz(fizzbuzz, X) :- 0 is mod(X, 15), !.
fizzbuzz(fizz, X) :- 0 is mod(X, 3), !.
fizzbuzz(buzz, X) :- 0 is mod(X, 5), !.
fizzbuzz(X, X).

print_fb(1) :-
fizzbuzz(Fizzbuzz, 1),
write(Fizzbuzz), nl, !.

print_fb(X) :-
Y is X - 1,
print_fb(Y),
fizzbuzz(Fizzbuzz, X),
write(Fizzbuzz), nl, !.

goal :- print_fb(100), halt.
>>
Should I learn java or C?
>>
>>57929885
C
>>
>>57929746
C++ was a mistake
>>
>>57929885
neither.
>>
>>57929885
C
faster to learn. Easier to use effectively.
>>
>>57930007
Come on, lad. Stop with the girly trans shit.

/dpt/ is a masculine thread for masculine programmers.
>>
File: heheheheheehe :3.jpg (19KB, 320x320px) Image search: [Google]
heheheheheehe :3.jpg
19KB, 320x320px
>>57930104
>Afraid to acknowledge your sexuality
clearly a closet homosexual.
>>
>>57929876
How is this different from procedural/whatever programming?
It'd be more interesting if it was a program that extrapolated what your intent was from a small set (accurately).
But honestly that sounds more like an IDE feature for other languages.
>>
>>57930104
as long as the balls don't touch
>>
>>57930104
Well do you have masculine programming images for the op? I did not think so..
>>
How would you format this to improve readability
    let words: Vec<_> = words_reader.lines().map(|line| line.unwrap()).collect();
>>
Please recommend good books on OO design/thought process.

> inb4 Real World Haskell
>>
>>57930243
>OO thought process
Oxymoron?
>>
File: ?.png (7KB, 120x120px) Image search: [Google]
?.png
7KB, 120x120px
what flags do you guys use to compile c programs?

right now i'm using
cc file.c -Wall -ansi -pedantic -Wextra -Wshadow
>>
>>57930265
Use -g.
>>
Finally done with AoC Day 10, too bad I usually get up 9 hours after the challenges are released, no chance to get in the leaderboards.
>>
>>57930265
set(CMAKE_CXX_FLAGS "-Wall -Werror -Wno-narrowing -std=c++14")
set(CMAKE_CXX_FLAGS_RELEASE "-static -static-libgcc -static-libstdc++ -O2")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
>>
Everyone should learn Idris
>>
>>57930328
>executable file is much much bigger when compiled with this flags

wew
>>
>>57930360
Do you only have a 40MB hard drive?
>>
>>57930356
>Everyone should learn obscure language
>>
>>57930372
>with my flags : 12KB
>with yours: 800KB
>>
>>57930328
Pointless with glibc.
>>
>>57930386
Storage is cheap. My time isn't. Dunno about yours.
>>
>>57930265
>ansi
Why?
>>
>>57930408
cheers
>>
>>57930407
What do you mean?
>>
>>57930328
Why do you use c make?
>>
>>57930424
It'll load dynamic modules at run time. Because "glibc lol".
>>
I was reading a rant shitting on nodejs and it said asyncronous + callbacks is the worst way to do concurrency.

Whats the best way? I was planning on toying with c++11 futures and promises but if there's a better way pls tell.
>>
>>57930462
Monads
>>
>>57930462
depends on the workload
>>
>>57930462
>>57930462
Use the right tool for the job. The strength of C++ concurrency is that your have the flexibility to use a concurrency model that is appropriate for the task at hand.

Note that generally speaking you should not use promises as they are usually unnecessarily low-level. Use std::async or std::packaged_task.
>>
Tight loops are the best.
>>
Yeah, Ocaml really is the best language.
>>
File: aaa.png (266KB, 765x1045px) Image search: [Google]
aaa.png
266KB, 765x1045px
What VPS does /dpt/ use?
>>
>>57930647
DO
>>
>>57930643
Idris or bust.
>>
>>57929726
thxm8
Also, is there a built in way to call the default constructor for every element in the array after it's already been called?
Or is the only way to do something like
for (int i = 0; i < 10; i++)
thing[i] = Thing();
>>
>>57930647
scaleway
>>
>>57929571
This is wrong though, this declares a funcstion thing that takes no arguments and returns a value of type Thing.

What you want for single object is either:
Thing thing{};


Or:
Thing thing = Thing();


For an array you do:
Thing things[size];


Which will default initialize them if the constructor takes no arguments.

>>57930702
If the constructor has been called then it's already constructor and you can't call it again. Doing what you've done will re-construct the object instead and assign it using the copy assignment.
>>
>>57930462
On the topic of this. I feel I've been thrown into parallelism from the top down.
Introduced to work systems before I learned the basics.

Where do you learn the basics?
>>
>>57930764
How do you declare an array of things on the stack without calling the default constructor?
>>
>>57930113
>Everyone who isn't a mentally ill faggot is a closet homo
"ok"
>>
File: faggot.jpg (42KB, 500x375px) Image search: [Google]
faggot.jpg
42KB, 500x375px
what does /dpt/ think of this coding genius?

https://www.youtube.com/user/shiffman
>>
>>57930799
You can't.
>>
>>57930668
>>57930735
What they like for seedboxes with handling DMCA requests?
>>
>>57930777
C++ Concurrency in Action. Not well written but the best book on C++ multi-threading atm.

I've ordered The Art of Multiprocessor Programming which received good reviews.
>>
>>57930838
No idea, don't use servers to seed torrents, you're probably better off asking in /ptg/.
>>
>>57930799
char *data[sizeof(Thing) * count];
Thing *pt = (Thing*)data;
>>
>>57930119
>How is this different from procedural/whatever programming?
You build a base of rules and facts with relationships. You must not care about the program flow, since once you've built criteria for the result, i.e. goal, Prolog finds its own way, comparing query conditions with the base.
>>
>>57930647
soyoustart
>>
>>57930685
Idris has nowhere near the performance of OCaml, let alone GHC.
>>
>>57930972
>>57930825
Ok. That's good to know.
>>
File: pos-neg.png (73KB, 1437x721px) Image search: [Google]
pos-neg.png
73KB, 1437x721px
such a beautiful language
>>
>>57930643
Reason is better since it can attract more hipsters.
>>
File: kumiko_tired.png (1MB, 697x819px) Image search: [Google]
kumiko_tired.png
1MB, 697x819px
Advent of Code day 2 solution using goroutines to simulate the bots and channels for the communication.

https://gist.github.com/Soreil/7d799d53d068f133b5d800bc6499f8f2

There is some racy map access in it, turn off the detector or give is 3-4 tries for it to not fire.

I ctrl+f'd to get the adresses of the goroutines it finds for the pair 61 and 17 and looked them up in the map.

I should have used a waitgroup for the outputs instead of a silly time.After but I wasn't sure ahead of time how the bots would flow.

Overall I kinda like it in a way.
>>
https://www.reddit.com/r/dailyprogrammer/comments/5h40ml/20161207_challenge_294_intermediate_rack/
http://pastebin.com/GQWMhD4h
I feel there's room for improvement though.
>>
http://www.strawpoll.me/11842853

What level of abstraction is acceptable for you?
Languages like Go are good for corporations since they can throw away all monkeys and hire new ones without problems. Less complexity = less coder's qualification required.
With Haskell you can write very expressive, terse and reliable code. But until you understand the paradigm and learn the Prelude, you are not very productive and you can't attract committers.
>>
Fixed the little race condition.
go func() { b[c.receive.bot] <- c.receive.chip }()

        
go func(ch chan int) { ch <- c.receive.chip }(b[c.receive.bot])


This eliminates the map access from happening after the goroutine has started.
>>
>>57931525
post your fucking solution in the reddit thread for fuck's sake, what's the fucking point of posting it here?
>>
>>57931543
(You)'s
>>
>>57931469
>There is some racy map access in it, turn off the detector or give is 3-4 tries for it to not fire.

Fix it you nerd.
>>
>>57931568
I did senpai
>>
>>57931573
Yeah I posted before I got to your other post.
>>
File: aeda0dca149624feea3eb0a0e578f53b.png (108KB, 1224x771px) Image search: [Google]
aeda0dca149624feea3eb0a0e578f53b.png
108KB, 1224x771px
Hello, I just completed my first programming class. We used psuedocode in that class. With the help of google I was able to translate one of my assignments from that class into python, and it works! I had a ton of fun doing this, I don't know why they didn't just use python in the class it's actually easier than the psuedocode
Pic is psuedo, this is py
from __future__ import division
#Declarations
#Constants
WIDTH_PROMPT = "Please enter the width of the wall in feet: "
LENGTH_PROMPT = "Please enter the length of the wall in feet: "
PAINT_PROMPT = "Please enter the price for a gallon of paint in US dollars: "
DOORWAY_PROMPT = "Please enter the number of doorways in the wall: "
GALLONS_NEEDED_PROMPT = "Gallons of paint needed: "
TOTAL_COST_PROMPT = "Total cost of paint for job: "
WELCOME_PROMPT = "This program will allow you to calculate the area of a wall and how much it will cost to paint it!"
END_LINE = "Calculations complete"
PAINT_COVERAGE = 350
DOORWAY_SIZE = 14
#Variables
wallWidth = 0
wallLength = 0
wallArea = 0
paintPrice = 0
gallonsNeeded = 0.
doorways = 0
#Functions
def housekeeping():
print(WELCOME_PROMPT)

def detailLoop():
wallWidth = input(WIDTH_PROMPT)
wallLength = input(LENGTH_PROMPT)
doorways = input(DOORWAY_PROMPT)
paintPrice = input(PAINT_PROMPT)
wallArea = (wallWidth * wallLength) - (DOORWAY_SIZE * doorways)
gallonsNeeded = wallArea / PAINT_COVERAGE
paintPrice = paintPrice * gallonsNeeded
print str(GALLONS_NEEDED_PROMPT), gallonsNeeded
print str(TOTAL_COST_PROMPT), paintPrice

def endOfJob():
print str(END_LINE)

housekeeping()
detailLoop()
endOfJob()
>>
C or C++?
>>
File: 1459880941714.png (143KB, 229x345px) Image search: [Google]
1459880941714.png
143KB, 229x345px
>adapt an algorithm from a git repository for my project
>often used function
>initialises for every call an object with over 113 floats
why is that allowed?
>>
>>57931640
you can actually skip setting all those variables to 0
>>
>>57931640
>I don't know why they didn't just use python in the class it's actually easier than the psuedocode
I've been there. Pseudocode is retarded as fuck.
>>
why wont this work, its supposed to be javascript

for (var i = 1; i > 100; i++){
if (i%5===0 && i%7===0){
console.log("Fizz Buzz");
}
else if (i%5===0){
console.log("Fizz");
}
else if (i%7===0){
console.log("Buzz");
}
else{
console.log(i);
}

}


please go easy on me im a fucking noob
>>
>>57931714
I strongly disliked my female 4 foot 3 400 pound teacher who made us use a book written by a similarly ugly female. In that book it said it was good practice to always initialize your variables. In this case is that incorrect?
>>
If I want to fiddle with some low-level graphics programming, is WebGL sufficient or do I need to go full C++?
>>
>>57931741
>WebGL
>C++
>low-level

Apply yourself.
>>
>>57931725
Pseudocode is fine, requiring specific syntax for it is dumb and pointless because as he says you might as well learn an actual language while you're at it.
>>
>>57931734
well you have to init them if you wanna use them but setting them to 0 is useless when you're never gonna use that value. I don't know python though.
>>
>>57931731
i > 100
>>
>>57931776
whats the problem here? it will run untill i reaches a value larger than 100? when i run it it just doesnt print anything even if i change it to i === 100
>>
>>57931734
>>57931774
nevermind, you have to set it to 0 because it's a global variable. just forget what I told you
>>
>>57931773
>>57931725
That was more or less my exact argument. We have this text and she demands that we "follow all of the conventions" from it. The problem is that a lot of the conventions are contradictory and pointless. One thing that comes to mind is how in one of the first chapters there is a paragraph explaining local vs global variables. For the rest of the book every single variable is global even when it could have been local to a module. Or the mandated. We had to make a "housekeeping" module with at least a welcome message. When I write a simple program and modularize it differently and explain why I did so I lost point, even though my explanation of the decision showed that I understood why the book did what it did and why I made the choice I did.

I silently raged through the entire class even though it was the first programming class I've ever taken.
>>
>>57931795
"i is 1. while i is over 100, ..."
Does this make sense?
>>
>>57931795
It will run as long as the condition is not met anymore. So it does nothing for i>100 because initially i=1and that's less than 100. Try i<=100.
>>
>>57931731
>failing at fizzbuzz
>>>/g/wdg/
>>
>>57931820
oh i see
i thought the first part meant the start point (i = 1) and the second part meant end point instead of while

thanks it works now
>>
>>57931860
come on man all i know is some very basic c++ and ive completed HTML CSS and Javascript courses on Codecademy
>>
Is it safe to use 64 bit atomics on a 64 bit cpu in a program that is compiled 32 bit?
>>
>>57931913
>all i know is some very basic c++
no, you don't
>>
Hello I am beginner cmd coder. I am also learning some hacking.
>>
>>57931931
I'm not sure, wouldn't they need two registers meaning there could be a fuck up in between setting each register thus making them non-atomic?
>>
>>57931913
That is the culture here. Just keep learning guy. I'm already 24 years old and I just finished my first semester of college. I recommend picking up a book on logic. I hated my logic course because of the teacher's rules but all in all I am much better off than I was before I took it.
>>
>>57931879
i > 100 (i greater than 100) is just the condition (logical expression) that's checked every time.
If it fails the first time you never do the loop.
So you want to do it while i is less than 100. Written out that's i < 100
>>
File: 1461870747945.jpg (27KB, 393x459px) Image search: [Google]
1461870747945.jpg
27KB, 393x459px
Anyone know a good python book for someone who's familiar with C/C++/C#?
>>
>>57932075
Just read the official manuel.
>>
>>57932075
cute
>>
I just translated one of the questions from my final project in that logic class to python. This one was much harder. Very fun debugging it since I know 0 python, everything was found on google. Can you guys please point out any bad practices or things I could improve?

import locale
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
#declarations
WELCOME_PROMPT = "Welcome to the Jumpin' Jive coffee shop goy!"
ERROR_PROMPT = "Sorry, we don't carry that item."
QUERY_PROMPT = "Enter the add-on's you would like or quit to finish your order: "
PRICE_PROMPT = "Total price of your coffee is "
TY_PROMPT = "Thank you for choosing Jumpin' Jive!"
product = ["Whipped cream","Cinnamon","Chocolate sauce","Amaretto","Irish whiskey"]
prices = [0.89,0.25,0.59,1.59,1.75]


def housekeeping():
print WELCOME_PROMPT

def detailLoop():
userQuery = " "
BASE_COFFEE_PRICE = 2.0
totalPrice = 0
foundFlag = 0
print "You may add ",str(product)," to your coffee."
userQuery = raw_input(QUERY_PROMPT)
while str(userQuery) != "quit":
for i in range(5):
if userQuery == product[i]:
foundFlag = 1
print product[i]," costs ",prices[i]," and has been added to your coffee"
totalPrice = totalPrice + prices[i]
if i == 4:
if foundFlag == 0:
print(ERROR_PROMPT)
foundFlag = 0
userQuery = raw_input(QUERY_PROMPT)
totalPrice = totalPrice + BASE_COFFEE_PRICE
print PRICE_PROMPT,locale.currency( totalPrice )

def endOfJob():
print(TY_PROMPT)

housekeeping()
detailLoop()
endOfJob()
>>
>>57931381

It is. What are you trying to do?

Also, this:

getMultipleLines n = replicateM n getLines

-- went with a list instead of a triple here
counts = map length . group . sort . map sign
where sign x = if x == 0 then 0 else div x (abs x)
>>
>>57932404
Nearly forgot:

import Data.Function (on)

divInts = on (/) fromIntegral


Composing non-unary functions can be awkward. I often end up resorting to arrows, particularly when zipping things.
>>
>>57931796
Their global nature isn't used though, so it really doesn't matter. The initialization is pointless as you originally stated.

>>57931640
Your teacher might've wanted to teach you strict typing which python drops. Also your functions are kind of strange. The housekeeping and endOfJob functions are pointless, and your detailLoop isn't looped.
>>
>>57932281

i'd use a dictionary of {name: price} for the products, then you can look the names up directly ("if userQuery in products:" etc) instead of using an index variable and 2 lists.
>>
>>57932577
yeah, I know but I didn't want to confuse him.
>>
File: 1.png (2KB, 404x404px) Image search: [Google]
1.png
2KB, 404x404px
anyone here uses redshift?


i have a c program with 85 lines that does the same thing
>>
>>57932704
I just write to /sys/class/backlight/
>>
>>57932756
nice

didnt know about that
>>
>>57932281
>>57932591
What this anon said, use a dictionary and query it with the user input. Catch key errors and print the error prompt, otherwise sum the price.

Also python uses the True/False boolean literals, which would make more sense than 1/0 for foundFlag, obviously the 1/0 still works as they will cast to the appropriate boolean value, but you should use True/False for readability. You only really need to use integers for boolean values in C.
>>
>>57927950
Symbolic perturbation in C++. I am trying to figure out the degeneracy in the code..
>>
>>57932784
Yeah, it's handy.
>>
>>57932281
>>57932786
Also if you use lower() and then capitalize() on the input strings you'll remove case sensitivity on the input
>>
>>57928579
Just type #include "arrayfun.hpp"
>>
>>57932867
>>57932786
>>57932591
Thanks alot guys. I'll get to google and try to learn how to implement those improvements and post it in a little while.
>>
File: mfw.gif (2MB, 170x127px) Image search: [Google]
mfw.gif
2MB, 170x127px
>mfw I realized that garbage collection is more efficient than manual memory management
>>
>using namespace std is retarded because i made a function called cout
>>
>>57933204
Good garbage collectors are the most impressive piece of CS we have.
>>
>>57933204
Yeah i think working as a trashman is better than working on code.
>>
>>57930315
The leaderboard is capped only 3 minutes after puzzles are released, there's no way in hell to get any score when you have no-life redditors patting themselves on the back for using python itertools.
>>
>>57932480
... you'd rather write
on (/) fromIntegral
instead of
fromIntegral a / fromIntegral b
? This isn't fucking code golf.
>>
>>57933385
Meh, last year I'd been awake at the time they released the puzzles and I made it to the leaderboard 5 times so it's definitely doable but nowadays I work late nights so I usually go to sleep an hour or two before the new puzzles unlock.
>>
>>57933416
Not for that example, but like I say, it's useful for composing non-unary functions.

Are you the poster of >>57931381
>>
>>57933459
>Are you the poster of >>57931381

No.
>>
>>57933492
Fair enough. You seemed pretty annoyed, so I thought you might have taken it as criticism or something.
>>
who else here /spendsMoreTimeOrganizingCodeThanActuallyWritingIt/?

How the fuck do I stop?
>>
i like to have some episodes of my favorite show run in the background while i go to sleep.

so years ago i made a little program that starts a certain number of episodes one after another and then shuts down my laptop

now i'm interested in doing the same thing, but with my tablet. i have no clue about programming apps tho. it's an android tablet.

is this doable?
>>
>>57933804
tbf the end game of industry development is pure design
>>
>>57933804
Some forethought is always a good thing, but if you're just constantly rewriting things to do things in less lines of code and including multiple side effects in every line, please stop.
>>
>>57933804
It's better to do things beautifully and well documented than to golf it.
>>
>>57931697
Good bit of C, then C++ then come back to C if you feel you need or want to.
>>
I need to make a program on java that involves bunch of classes that take methods from each other.
Anyone could give me good ideas for a simple program?
>>
>>57933964
holocaust simulator
>>
>>57933964
Take methods from each other? Like inheritance or just classes calling each other?
>>
>>57933988
Inheritance
it can be about basically anything but I'm a total retard in CS so I want something simple to pass the class
>>
HI guys! I want to get serious with programming(aka writing at the very least a program/exercise a day). So I was thinking on getting a nice text editor, so that I don't have to
int main(int argc, char *argv[ ]) 
{
}

everytime.
So, which text editor do you recommend for a C beginner. I have been using nano, but I want to practice other text editors. Thanks in advance.
>>
Any idea how to fix this?
let score = word.chars()
.zip(word.chars().enumerate())
.map(|(c, i)| tile_points[&c] * i + 1)
.sum();

error[E0277]: the trait bound `{integer}: std::ops::Mul<(usize, char)>` is not satisfied
--> src/main.rs:52:39
|
52 | .map(|(c, i)| tile_points[&c] * i + 1)
| ^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Mul<(usize, char)>` is not implemented for `{integer}`
>>
>>57934046
vim
>>
kys hasklel sperg rust puzzle-oriented nazi sjw admin
>>
>>57934046
Lemme rephrase my question. So that I don't have to write
#include <stdio.h>
int main( int argc, char *argv [ ])
{
}

evertime I am about to write a program. In other words, make it easier for me to work.
>>
>>57934046
The two main ones everyone uses is vim and emacs. Both have a bit of a learning curve, but try both and see what you think
>>
>>57934046
Unless you're writing little toy programs every day, you don't need to write main functions that often.
Also, it's char **argv.

Also, just use nano.
I use nano and I can't stand other editors that automatically indent, attempt to autocomplete your variable names and even appends semicolons.
Who uses this shit.
>>
>>57934086
>>57934101
Alright, I have heard about both of them. I think I will try vim, eventhough the general consensus is that emacs is better.
>>
>>57934082
I haven't used Rust but it looks like you need to cast tile_points[&c] to an integer
>>
>>57934100
I sincerely hope you don't actually put trailing and leading spaces around your parentheses and your brackets whilst programming.
>>
>>57934153
>eventhough the general consensus is that emacs is better.
it's not really, vim is more popular in general than emacs, emacs is just found more on very specific cultures like 4chan or GNU forums. If you like vim bindings you'll hate emacs bindings and vise versa
>>
>>57934153
Once you choose one path, do not deviate from it. Such is the way since the medieval times of 1956.
>>
>>57934110
> Also, it's char **argv
Ew
>>
>>57934110
I get your point, but I want to become familiar with those text editors to see if I like them or not. Nano will always be there.

>>57934169
I don't, this was just an example. Is that frowned upon? I didn't know, I just made it this way in the example so that the array brackets dont look like a rectangle([]).
>>
File: 1479930533572.png (284KB, 586x634px) Image search: [Google]
1479930533572.png
284KB, 586x634px
I'm procrastinating on my work by shitposting on /g/.
>>
Incredibly stupid question coming through.

Is there any way to interpret JavaScript on Linux without fucking with the DOM/using a browser?
>>
>>57934153
I only suggest vim because it's what I use as a text editor, but I only use a text editor when I'm editing configuration files, writing brief scripts, or absolutely need to work directly on a headless machine. I think vim lends itself to quick edits while emacs might be better for extended programming, but I've known plenty of people whose one or the other as their sole editor. Also I'd advise against suggesting one is better than the other, as you're only poking at an old and wretched war of opinions
>>
>>57934110
>>57934191
Is it really necessary? I mean, its literally making an indirection TO an indirection. Is that better for your programs, or is it just making it "fancier" for no reason. I am seriously asking as a beginner.
>>

#include <stdio.h>

int main(int argc, char* argv[]) {

}



objectively the best
>>
>>57934208
SAMEE
>>
>>57934213
you can grab node js with most distribution's official repos as a runtime
>>
>>57934224
>>57934201
I meant to link this post. Not this one>>57934191
>>
Objectively the best.

#include <cstdio>

auto
main(
const int argc,
const char **argv
)
->
int
{
return 0;
}
>>
>>57934227
Not for function definitions faggot.

Objective best style:
int main (int argc, char* argv[])
{
while (true) {
doShit();
}
return 0;
}
>>
>>57934270
>brace on new line in function definition
it's shit, time to stop
>>
>>57930408
What advantage is there in statically linking the standard library?
It has to be a big enough advantage that it's warranted you to actually do it.
>>
>>57934270
> Pointless line brake
> Camel case
Do you even C?
>>
>>57930531
I want to fuck that tight loop if you get what I mean.
>>
>>57934307
>>57934283
>never read K&R
I'll give you the camel case criticism though. I'm just a lazy faggot who hates having to type underscores.
>>
>>57934213

you can install google's v8 as a standalone interpreter, i think.

https://github.com/v8/v8/wiki/Building%20with%20Gyp
>>
>>57930328
>-static-libgcc
I hope you don't use exceptions.
>>
>>57934270
this

for function definitions, the line break makes the function declaration look like a title and easily stands out from the body of the function.

for loops and conditionals, line breaks just end up adding a lot of wasted lines and makes the actual meat of the code more difficult to read
>>
>>57934224
>>57934256
**argv is not making an indirection to *argv[] it's the same thing. It's just visually different
>>
File: 1478800746070.jpg (36KB, 228x228px) Image search: [Google]
1478800746070.jpg
36KB, 228x228px
It's been a day and I haven't gotten any responses on Stack Overflow. I never get responses on Stack Overflow. Can one of you guys just please help me out. I would appreciate it so much.
>>
>>57930265
-Wfatal-errors -march=native -O3 -std=gnu11
>>
>>57934384
There's a copy of K&R C sitting right next to me faggot. Doesn't mean I have to follow their shitty practises every where I go like some sort of sheep. Do you also use gets(), scanf() and prototype your functions in the same source file as the definitions?
>>
>>57934442
Yes, install Gentoo
>>
>>57934442
shit forgot the link

http://stackoverflow.com/questions/41067414/im-trying-to-create-a-display-which-shows-a-number-of-components-changing-color
>>
>>57934224
>>57934256

it's a matter of taste. i like "char *argv[]" because it reads as "pointer to array", but arrays are implemented as pointers anyway so they're equivalent.
>>
>>57934450
O3 is a meme you dingus
>>
>>57934442
once made a question about win forms and got several upvoted replies about web forms while my question got about 10 downvotes
>>
>>57934082
let score = word.chars()
.enumerate()
.map(|(i, c)| tile_points[&c] * i + 1)
.sum();
>>
>>57934454
I usually buffer files before reading them, but yes, there's nothing wrong with using the scanf family functions.

>>57934462
Why do people use [] in function arguments?
The compiler treats them as their own type and not as a simple pointer.
This is especially true if you write something like arr[10][50], you won't be able to pass a simple **arr pointer to it.
>>
>>57934450
>gnu11
Kill yourself
>>
Just cracked a program for the first time.
hell flippin yeah, the world is my oyster.

i'd like to take this moment to thank java bytecode for being so readable, yet incredibly annoying
>>
>>57934605
you seem upset
>>
>>57934613
What program
>>
>>57934701
Charles Proxy.

I'm obviously not the first one to do it, but I wanted the latest Linux version, which isn't cracked at the moment.
>>
File: magician.jpg (3MB, 2448x3264px) Image search: [Google]
magician.jpg
3MB, 2448x3264px
>>57927950
hey /dpt/
what do you love most about C++
>>
>>57933307
>I don't understand the purpose of namespaces
>>
>>57934784
HKTs
>>
File: CrORLwRW8AA7PE6.jpg large.jpg (57KB, 720x626px) Image search: [Google]
CrORLwRW8AA7PE6.jpg large.jpg
57KB, 720x626px
>>57927950
Does anybody have trouble programming for other people?

I have voluntarily contributed hundreds of lines to opensource projects but whenever somebody (usually one of the developers) asks me to implement "x" in a different way or to fix "y" (a bug that i did not introduce) I get stuck. I feel really depressed.

Once in a while a friend offers me a freelancing job and I take it because it's great money (3x what i get from my fulltime it support job). It's excruciating. Right now I'm working with some Oracle stuff and I kind of wish to die because of it. It's not even hard stuff. I can easily do it but Christ I just don't want to.

I'm starting to think I'm a closet NEET.
>>
>>57934789
>no polymorphic recursion
>>
>>57934805
True.
>>
>>57934525
Thanks senpai, it works like a dream
use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;

const WORDS_FILENAME: &'static str = "enable1.txt";

fn main() {
let tiles = env::args().nth(1).expect("Usage: app TILES");
let mut tile_points = HashMap::new();
tile_points.insert('a', 1);
tile_points.insert('b', 3);
tile_points.insert('c', 3);
tile_points.insert('d', 2);
tile_points.insert('e', 1);
tile_points.insert('f', 4);
tile_points.insert('g', 2);
tile_points.insert('h', 4);
tile_points.insert('i', 1);
tile_points.insert('j', 8);
tile_points.insert('k', 5);
tile_points.insert('l', 1);
tile_points.insert('m', 3);
tile_points.insert('n', 1);
tile_points.insert('o', 1);
tile_points.insert('p', 3);
tile_points.insert('q', 10);
tile_points.insert('r', 1);
tile_points.insert('s', 1);
tile_points.insert('t', 1);
tile_points.insert('u', 1);
tile_points.insert('v', 4);
tile_points.insert('w', 4);
tile_points.insert('x', 8);
tile_points.insert('y', 4);
tile_points.insert('z', 10);

let mut best = (String::new(), 0);

let words_handle = File::open(WORDS_FILENAME).unwrap();
let words_reader = BufReader::new(words_handle);
for word in words_reader.lines().map(|c| c.unwrap()) {
let mut tmp_word = word.clone();
for tile in tiles.chars() {
if let Some(i) = tmp_word.find(tile) {
tmp_word.remove(i);
if tmp_word.len() == 0 {
let score = word.chars()
.enumerate()
.map(|(i, c)| tile_points[&c] * i + 1)
.sum();
if score > best.1 {
best = (word, score);
}
break;
}
}
}
}

println!("{} {}", best.0, best.1)
}
>>
>>57934554
Probably just because they can. The compiler only treats them differently in their declaration scope, when they're passed they're turned into double pointers.
>>
>>57934665
I FUCKING AM UPSET
WHY WOULD ANYONE FUCKING USE GNU C
>>
>>57934810
void*
>>
>>57934784
Operator overloading.
>>
>>57934858
Doesn't really count.
>>
>>57934841
or whatever pointer depth is relevant
>>
Why am I getting null when trying to read from a file in Java? The file has text in it, but won't print. The code is:
BufferedReader testIn = new BufferedReader(new FileReader("test.txt"));
out.println(testIn.readLine());
>>
>>57934845
typeof
int x = {( some_fn(); 3; }); // x = 3, good for macros

typedef int v4si __attribute__ ((vector_size (16)));

some that come to mind on the spot.
>>
>>57934845
They made c not trash, tbqh
>>
>>57934921
Two things.
One the Reader will read from a specific location, the same location where it creates filles if you make a PrintWriter, so make sure your file is there. And Two, ".txt" is not necessary. If you save your files as "test.txt" they will be saved as "test.txt.txt", and you don't need to include extensions when calling files.
>>
>>57934790
cheer up lad
>>
File: 1481401820.png (33KB, 224x1637px) Image search: [Google]
1481401820.png
33KB, 224x1637px
help, this is getting out of hand
>>
>>57935011
Also to make things just a little easier for you, the place where your code most likely wants your files is in the very top file of the program where everything else is housed. If your Program is called "test" Put it in the test folder, along with the nrc and build folder. Try that.
>>
>>57935011
I have a printwriter which can write to files fine. It's in the same folder as the .java and .class files.
And I get an exception "File not found" when I don't include the file type in the constructor.
>>
>>57935059
put them all in one massive module : ^ )
>>
>>57934845
__attribute__
__builtin functions
inline asm
address of labels
typeof

Standard C is insufficient for writing good code unfortunately.
>>
>>57934921
>>57935011
>>57935064
Solved it.
My printwriter stream was still open when trying to read from it. Closing the stream worked fine.
>>
Which compiler should I use on Windows? I can't find any benchmarks for mingw, clang and msvc anywhere. I'm developing on Linux so I don't need a fast compiler on Windows, but whatever produces fastest binaries.
>>
>>57935093
No… We actually decided against
projectname-prelude
recently.

Need to restructure stuff later anyway, it's just a test module.
>>
>>57935111
If you're developing on linux just use what ever compiler is closest to what you're using. (ie. MinGW if you're compiling with gcc or g++, clang if you're compiling with clang, etc)

Unless you're writing a 3d game engine it literally doesn't matter.
>>
>limit yourself with recursion when you can solve a problem iteratively
why.png
>>
>>57934966
>>57935109
I'm not convinced that these improve C programs.
>>
>>57935133
I-I was kidding anon, but you're kind of scaring me now. Is it standard practice among python programmers to do shit like that?
>>
>>57934208
>on Saturday
Well...
>>
>>57935111
It's pretty much a wash these days.
None of clang, gcc or msvc is significantly better than the other in terms of optimizations, they all have certain good cases and certain pathological cases.
clang tends to have the best C++ standards support though, and clang and gcc have those nice sanitizers.
>>
>>57935153
Not memeing, but when your recursion only goes a few deep, it's not worth the time to make an iterative loop.
>>
>>57935177
>he doesn't work _all the time_
what kind of programmer are you
>>
>>57935153
It's easier to figure out recursive solutions sometimes and the equivalent iterative solution is usually slightly harder
>>
>>57934270
>>57934263
>>57934227

public static void Main(String[] args){
System.out.println("Suck my dick");
}
>>
>>57935148
>>57935179

My code is totally portable though, and setting up mingw is kind of a pain on Windows. I've also heard gcc suffers some overhead on Windows since it's ported over from Unix, is that true?

Also, probably a dumb question, but do I have to worry about C++ runtimes depending on the compiler? This has never even occurred to me on Linux because Linux has proper package management
>>
>>57935195
>>57935185
but unless you go for tail recursion from the start your programm will eventually shit the bed
you will never have that problem with an iterative solution
>>
Hi can anyone help with this?
This is my data sets:

list of car manufacturers

car_manu = ['ford', 'vauxhall', 'toyota', 'renault', 'volkswagen']

car_dict = {
ford : 'focus', 'fiesta'
vauxhall : 'corsa', 'astra'
toyota : 'aygo'
renault : 'clio'
volkswagen : 'golf', 'polo'


If I was to do

for cm in car_manu:
for key in car_dict:


so that loop iteration one would be
focus
fiesta
loop iteration two
corsa
astra


What is the syntax pleasE?
>>
File: 1481402279.png (369KB, 1033x1593px) Image search: [Google]
1481402279.png
369KB, 1033x1593px
>>57935165
>Python

anon…

>>57935177
Not him but I'm working right now, Saturday is comfy day to work on: noone bothering you and can focus; and personally the extra hours just mean I can work less or take a day off in middle of week
>>
>>57935240
Your code better be pretty fucking slick if your biggest performance issues will be compiler dependent
>>
>>57927950
who /fizzbuzz/ here
fb :: Integer -> IO ()
fb 100 = return ()
fb n =
do
if (mod n 3) == 0 && (mod n 5) == 0
then print("FizzBuzz")
else if (mod n 3) == 0
then print("Fizz")
else if (mod n 5) == 0
then print("Buzz")
else print(show n)
fb (n+1)
main = fb 1
>>
>>57935240
>and setting up mingw is kind of a pain on Windows
I mean .... what? setting it up on windows?
what are you talking about?
just slap that fucker on your drive and start
>>
>>57935253
Many programs have upper bounds, recursion is fine in these cases.
>>
File: 583.jpg (54KB, 600x600px) Image search: [Google]
583.jpg
54KB, 600x600px
What music do you listen to when you code?
>>
>>57935261
I don't fux wit haskell tbqh senpai

you're on your own.
>>
File: Geogaddi.jpg (18KB, 220x202px) Image search: [Google]
Geogaddi.jpg
18KB, 220x202px
>>57935311
mein neger
>>
>>57935311
Nothing. I have to program in absolute silence or else I get distracted.
>>
>>57935261
>generics
>aeson

do other languages do this yet
>>
>>57935257
Help please someone

        for key in d:
if key in d:
print key, d[key]


This doesn't filter, it returns all values for everything.
>>
>>57935373
I don't understand your question
it's obvious what's wrong
what do you want to do?
>>
File: aux88[1].jpg (67KB, 2100x2100px) Image search: [Google]
aux88[1].jpg
67KB, 2100x2100px
>>57935311
[spoiler]I NEED TO FREAK[/spoiler]
>>
>>57935360
Hm, I think PureScript has generic deriving…? We don't actually use JSON all that much though, it's either only used for some machine-parsable CLI output or we're generating instances from a schema (using
aeson-schema
).
>>
>>57935311
https://www.youtube.com/watch?v=lmTSQZjR3DE
HAVE YOU
EVER TASTED SKIN
>>
>>57935373
for every element in the list
if the element is in the list
print the element
>>
>>57935409
>>57935452
I think he meant to use his car manufacturer list first and then the model dictionary second
>>
>>57935452
I only need the syntax for the value from a dict? not the key
>>
I created two arrays - one with randomly generated numbers, the second with user inputed numbers. How can I compare the two arrays for similar numbers?
>>
File: uh.png (178KB, 703x897px) Image search: [Google]
uh.png
178KB, 703x897px
>>57935311
anything goes...
>>
>>57935486
You have a poor grasp of both python and english so you aren't going to be very successful here... There's already enough information in the thread to solve your problem
>>
>>57935257
>>57935373
>>57935452
>>57935473
>>57935486


HERE YOU KEKS

car_manu = ['ford', 'vauxhall', 'toyota', 'renault', 'volkswagen']
car_dict = {
"ford" : {'focus', 'fiesta'},
"vauxhall" : {'corsa', 'astra'},
"toyota" : {'aygo'},
"renault" : {'clio'},
"volkswagen" : {'golf', 'polo'}
}

for brand in car_manu:
for ele in list(car_dict[brand]):
print (ele)
>>
>>57935517
Doing someone's homework should be a bannable offense
>>
>>57935536
this
>>
>>57935513

Highly unusual selection.
>>
>>57935517
print('\n'.join([ele for ele in [list(car_dict[brand]) for brand in car_manu]]))
>>
>>57935496
for(int i = 0;i<ARRAY_SIZE;i++)
{
if(array1[i] == array2[i])
{
//Do stuff
}
}
>>
What are the things to avoid if I want to be a Christian programmer?
>>
>>57935588
bad
e.g.
[1, 3, 5]
[2, 1, 3]
gives nothing
>>
>>57935568
doesn't even work you retard
you're trying to join a list of lists??

you have to flat out the list first and then print its elements
print('\n'.join(ele for ele in sum([ele for ele in [list(car_dict[brand]) for brand in car_manu]],[])))
>>
>>57935595
Avoid the ditor of the devil, Vi, and its many faces and disguises, like Vim and Neovim and Spacemacs (This one is extra heretic since someone thought staining the holy editor of all chiristianity "Emacs", with the bloood of the devil was a good idea.).

So, for you I recommend using Emacs.
>>
New thread:

>>57935681
>>57935681
>>57935681
>>
>>57935588
I understand that it should pick the first element of the first array and check it against all the other elements of the second array, but I don't know how to put it on code.
>>
>>57935311
I listen to my intrusive thoughts.
>>
>>57935710
what language are you using?
>>
>>57935748
java
>>
>>57935496
Compare the entirety of the array to the entirety of the other? Or just find whether a1[i] has an equivalent element within a2[]?
>>
File: cozybirb.jpg (62KB, 300x300px) Image search: [Google]
cozybirb.jpg
62KB, 300x300px
//case 1
while(true) {
MyClass mclass = getClassStack();
//do stuff to mclass
}

//case 2
while(true) {
MyClass* mclass = getClassHeap();
//do stuff to (*mclass)
delete mclass;
}

which of these generic cases would theoretically be faster, assuming MyClass is the same for both cases and they aren't both running at the same time?

getClassStack() creates a MyClass on the stack and returns the value of it to be deep copied into "mclass" with the '=' operator

getClassHeap() creates a 'new' MyClass on the heap and returns a pointer to it to be assigned to "mclass", which then of course needs to be deallocated

this isn't homework help, i promise. i'm making a game in which the event queue travels into the game loop every frame. theoretically the event queue will rarely be larger than 1 or 2 elements unless there's a freeze or massive performance drop.
>>
>>57935595
The Bible.

But more seriously, what the actual fuck does your faith have to do with your code?
>>
>>57935595
CIA Niggers
>>
>>57935641
I got it to work in the end, had to import a module called 'collections' and use iteritems method
>>
How would I go about getting a nested integer from a for loop and writing it to a file?

I'm creating a quiz, and I want to be able to save the game's state, which includes getting the integer which controls what player's turn it is. This integer is nested in the "round" for loop, so it wipes itself to null even when it's declared as a global variable.

What would be the best way of getting this variable, or something like it, out of a for loop?
>>
>>57936964
Nigger you have to be more specific.

What language?

What's your target operating system?

What (if any) third party libraries are you using?

To give you an incredibly generic answer, add a log function that is called every iteration of your game loop.
>>
>>57937082
>Nigger
That's it, /dpt/ is finished.
R.I.P
Thread posts: 322
Thread images: 34


[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.