[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: 323
Thread images: 35

File: fizzbuzz of the christ.png (402KB, 1024x768px) Image search: [Google]
fizzbuzz of the christ.png
402KB, 1024x768px
Holy code edition
>>
First for quotient inductive types
>>
>tfw your test code is longer than your program
>>
File: OpenGL-ES-2_0-Reference-card.png (1MB, 1041x2677px) Image search: [Google]
OpenGL-ES-2_0-Reference-card.png
1MB, 1041x2677px
enginebabbies everyone

https://www.youtube.com/watch?v=NvHIpxJE2Ss

can't even get fucking tetris right

raw opengl masterrace
>>
File: B_lLJErWwAAnRkQ.jpg (46KB, 519x657px) Image search: [Google]
B_lLJErWwAAnRkQ.jpg
46KB, 519x657px
>>52331136
danks
>>
>>52331152
c
>>
>>52331152
Reverse the order of all characters expect the first/last?

C.
>>
File: baka.jpg (55KB, 555x720px) Image search: [Google]
baka.jpg
55KB, 555x720px
>>52331122
Jeez, why?
>>
>>52331152

pelborm
>>
i don't know what to do, I learned OOP, I want to create something but don't know what to make. Maybe I should just prepare for algorithms
>>
>>52331136
>ES

ebin :DDD
>>
>>52331152
i choose a)
>>
>>52331228
explain yourself
>>
>>52331244
im a retard thats why i chose a
>>
File: 3Rgtx3S.webm (2MB, 720x404px) Image search: [Google]
3Rgtx3S.webm
2MB, 720x404px
Ask your beloved programming literate anything.
>>
>>52331264
how do i get a gf ?
>>
>>52331264
What is a monad in Haskell?

>>52331179
>pic
nice specs
>>
>>52331136
SLAVE TETRIS NEW HIT GAME
>>
>>52331179
hyperefficiency
>>
>>52331088
wow, can someone explain that fizzbuzz
>>
>>52331136
what is this mickey mouse shit?
>>
>>52331333
print half of the string if i%3 (if 3 is a divisor) else if i%5
>>
>>52331333
i is the overall increasing number counter in a range from 1 to 101.
FizzBuzz is the word to be printed if i is devisible by 3 and 5. Otherwise it will be splitted by using the 4:8 slice.
>>
Anyone here familiar with graphics.py ?
I'we run into this really wierd problem.
dxy = NthFibonacci(i)
x = startPoint.getX() + dxy
y = startPoint.getY() + dxy

I am trying to make squares that have lengts equal to fibonacci numbers. do dxy is the ith fibonacci number.
The problem is this:
line 22, in <module>
y = startPoint.getY() + dxy
TypeError: unsupported operand type(s) for +: 'method' and 'int'

This is realy strange seeing how i do the same thing right above with
x = startPoint.getX() + dxy

Any suggestions?
>>
>>52331333
[0,1,2,3,4,5,6,7].map((i) => i*i%3)
[0, 1, 1, 0, 1, 1, 0, 1]


[0,1,2,3,4,5,6,7].map((i) => Math.pow(i,4)%5)
[0, 1, 1, 1, 1, 0, 1, 1]


Pretty simple from there.
>>
>>52331424
I've*
So* dxy is...
Maybe the getY() function is broken?
>>
What's the best way to evaluate if a certain website has specific words in it?

I'm looking to create a program that takes a list of companies and checks their website if they mention summer jobs/internships/student/etc
>>
>>52331122
Working for a company writing enterprise software in Java. This totally happens all the time.
Sometimes it's as ridiculous as a few lines code change and few hundred lines unit test to prove the bug was fixed.
I think the whole system I'm working on has near like 10k JUnit tests (which are mostly integration tests in fact but k).
>>
>>52331179
happens all the time to me when i'm writing config parsers or do some transformations.
>>
>>52331424
>>52331473
What value does getY() return normally? I can't see why it would fail on that line and not the previous.
>>
>>52331474
curl + grep ?
>>
if I did this in a job interview would I get kicked the fuck out? lol

     for(int i=1; i<101; i++){
if (i%3==0 and i%5==0){
cout << "fizzbuzz"<<endl;
} else if(i%3==0){
cout << "fizz" << endl;
} else if (i%5==0){
cout << "buzz" << endl;
} else {
cout << i << endl;
}
}
>>
>>52331136
>>
>>52331615
If you were working for me? Yes. Maybe not your average plebspace like IBM or JP Morgan Chase.
>>
>>52331615
>endl
yes
>>
>>52331615
yes
>>
>>52331658
Can you enlighten us to a better way of writing fizzbuzz in c++?
>>
>>52331683
maybe try using the AND operator instead of writing "and" ?
that way your code would at least work. but it's still relying on a lot of compiler optimizations
>>
>>52331668
I tried to write the most pleb way to do it
>>
>>52331553
in graphics.py there is something called a Point. Here the definitions:
Point(x,y) Constructs a point having the given coordinates.
getX() Returns the x coordinate of a point.
getY() Returns the y coordinate of a point.
Link to documentation: http://mcsp.wartburg.edu/zelle/python/graphics/graphics.pdf
(the documentations is super smal).
Another weird this is that adding a print statement like this:
dxy = NthFibonacci(i)
print(startPoint.getX(), startPoint.getY(), startPoint.getY() + dxy)
x = startPoint.getX() + dxy
y = startPoint.getY() + dxy

Gives me this:
print(startPoint.getX(), startPoint.getY(), startPoint.getY() + dxy)
TypeError: unsupported operand type(s) for +: 'method' and 'int'
320 251 252

So clearly it can calculate it yet its giving me errors.
>>
>>52331658
>code works
>is readable
>maybe two unnecessary lines, but gets the point across
elitist detected
>>
>>52331704
wait wat you can't write 'and' ?
>>
>>52331668
what is wrong with endl?
>>
What's the reason c++ streams require << or >> operators everywhere?
Instead something like this
std::cout("Object A ", a, " penis ", endl);
>>
>>52331704
it's a habit after writing in VHDL
>>
>>52331615
>using namespace std
>post-fix increment
>starting an index at 1
>flushing every line
>not i % 15

probably
>>
>>52331755
just write \n in the string

nothing wrong with endl really
>>
>>52331760
Because C++ makes a lot of very stupid design decisions.
>>
>>52331772
postfix increment gets optimized to prefix increment by every compiler if the current value of the variable is not used. but yeah, relying on compiler optimizations is bad
>>
>>52331772
what's wrong with postfix increment? it does the same damn thing in this instance; the binary would literally be identical
>>
File: lua.gif (5KB, 256x255px) Image search: [Google]
lua.gif
5KB, 256x255px
Why is Lua so popular? It seem like a really niche language now that I looked at it.
>>
>>52331755
I'm no Meme++fag, but I think endl flushes the buffer, while '\n' doesn't.
I think flushing the buffer is the behaviour you actually want here.
>>
>>52331760
<< and >> is more readable imo
>>
I'll ask this here as well because /wdg/ is so slow

In the long run is becoming a full time self employed web dev without any post high school education a good idea? I know that for now I will be able to provide for myself with good margins but what about in the long run? Any thoughts and ideas?
>>
>>52331704
>>52331731
You should write &&, but you absofuckinglutely can write 'and', you scrub. If you wanna be a smartass, try and at least be right.
>>
>>52331730
>code doesn't work
>unnecessary lines
>>
>>52331801
because gmod
>>
>>52331755
It's short for newline then a flush.
C++ waits until you have enough shit in the buffer to output then does it all at once or does it before an input because I/O is expensive. Doing it every line is stupid unless you need to flush the buffer for some reason or you need the output at that exact moment in when running.
>>
>>52331801
Lua is the undisputed god of embeddable programming languages. Outside of that, it doesn't see a huge amount of use.
>>
>>52331820
>You should write &&
which is what i said: the AND operator, dipshit.
>>
>>52331791
In that case, nothing, but when you start using it with objects it can create temporary copies that aren't needed.
>>
>>52331801
Why is python so popular?
Every fucking linux users know python and it's easy so it many retards will get drawn to it.

So why is Lua so popular?
Every fucking game developer knows Lua because it's used as scripting language in games/engines a lot.
It's also easy to it draws lot of retards to it.
>>
>>52331827
Still sticking to your guns ayy? Turns out your smartass was wrong though. Sucks, doesn't it.
>>
>>52331704
>Doesn't know about iso646
>>
>>52331806
fn(a, b, "test", c);
It's pretty fucking readable. And if you have problem reading that maybe you should not be programmer?
>>
>>52331827
it does work
>>
>>52331860
enlighten me ?
>>
>>52331882
http://en.cppreference.com/w/c/language/operator_alternative
http://en.cppreference.com/w/cpp/language/operator_alternative
>>
>>52331760
printf and other C I/O is still there if you want to use it.
>>
File: 1452026137949.jpg (77KB, 435x653px) Image search: [Google]
1452026137949.jpg
77KB, 435x653px
Is Project Euler worth doing?
>>
>>52331880
equally readable. If you have trouble reading << or >> maybe you should not be a programmer?
>>
>>52331858
>Lua is popular because it is used a lot
Genius
>>
>>52331928
Not him.
<< >> is 'readable', but is still ugly as fuck and completely retarded.
Do you know why no other language does their output like that, and chooses to use format strings instead?
>>
>>52331928
I have no problem reading it.
But there is no reason why it should work different than normal function.
>>
>>52331917
Yeah. But don't just brute force the problems. Work some math.
>>
>>52331179
The only thing that makes sense there is the hips, and they are just large male hips. Female hips have a completely different profile.
>>
>>52331858
>>52331940
Lua is popular because it's very simple and has a tiny ANSI C interpreter. If you embed Lua into your application, you only need to ship a few hundred kilobytes for the interpreter, instead of much more (possibly in order of hundreds of megabytes) for some other shit. Also, since Lua is ANSI C, it'll run on pretty much fucking any platform and can be compiled with almost any C compiler.
>>
>>52331718
>>52331553
>>52331424
When printing startPoint.getY() before it fails i get this as the print statement:
print("test", startPoint.getY())

>>test <bound method Point.getY of <graphics.Point object at 0x005D9F70>>

Does anyone know what that means?
>>
>>52331928
Also if you have something like
std::cout << x << y << 4 << z;

I wanted to shift y by 4 to left but I don't think it gets shifted.
Solution of course would be (y << 4) but I would argue that it's less readable than the normal way of writing functions.
I don't program in c++ so I don't know if it has << as shift operator but C should work in c++ so I assume << is also shifting operator.
>>
>>52331615
no you're supposed to do it like this
 
int main(){for(int i=1; i<=100; ++i)i%15==0?printf("fizzbuzz\n"):(i%3==0?printf("fizz\n"):(i%5==0?printf("buzz\n"):printf("%d\n",i)));}
>>
>>52332059
""""""""""""""readable""""""""""""""
>>
File: 1441895090211.jpg (55KB, 900x810px) Image search: [Google]
1441895090211.jpg
55KB, 900x810px
>>52331961
>>52331928

I made the whole thing more readable for everyone, don't worry

#include <iostream>
int main() ??<
for (int i = 0; i < 101; i++) <%if (i % 3 == 0 and i % 5
==0)??<std::cout << "fizzbuzz" << std::endl;??>
else if (i % 3 == 0) ??<
std::cout << "fizz" << std::endl;
??> else if (i % 5 == 0) <%std::cout << "buzz" << std::endl;??> else ??<std::cout << i << std::endl;%>??>??>


>mfw this compiles and runs perfectly
>>
>>52331801
It's very easy to learn. It can be embedded in anything and usually is (vim, lualatex, video games, etc.). It's fast (it's register-based, not stack-based like CPython) and the JIT is really fast. If you already know how to program it might take you 2-3 days to learn it completely.

Unfortunately, it seems to be losing a lot of steam recently. Look at the mailing list. Mike Pall left the JIT. And projectkepler is in perpetual maintenance mode. No one really wanted to leave 5.1 and it's killing the language (plus built-in integers in 5.3 being a pain in the ass).
>>
>>52332044
Ignore me. I found the problem. I worte

startPoint = Point(startPoint.getX() + dxy, startPoint.getY)

instead of

startPoint = Point(startPoint.getX() + dxy, startPoint.getY())
>>
Anyone knowledgeable about persistence in Haskell? I have a bunch of records I'd like to be able to save, preferably into a relational database. Any clean APIs that can generate a schema and bindings that just werks?
>>
>>52332048
Yeah those I/O operators are overloaded bitshift operators.
>>
Ayy guys how do you visualize memory when working with pointers
>>
>>52332112
But when you gave us an example, you wrote it correctly...
>>
>>52331917
who is this pisser kisser?
>>
>>52332135
List of boxes with shit in them. Of course they are multi-level so I can visualize what they point to if there are multiple-level of indirection.
>>
>>52332135
0s and 1s
>>
>>52332135
I usually think of some kind of array. You could also try to imagine a street with house numbers though, if it helps you.
>>
>>52332145
Yes. The error was further down in the code.
>>
>>52332134
so they just shift shit in and out of the buffer? That makes it pretty simple.
>>
>>52332210
No.
They can shift buffers but they can also shift bits in number which makes it really non-simple.
Somebody might even overload it to do something else when it comes even more of cluster fuck.
>>
I'm new here. Would anyone be willing to give me a few pointers on how to possibly solve a problem I am having with a program? I'm also new to programming, so I'm working on something for my sister that she needs for work for practice. I just don't want to ask for help if that's not welcome here...
>>
>>52332310
might help if you post the problem, jesus
>>
File: guesswho.gif (786KB, 300x168px) Image search: [Google]
guesswho.gif
786KB, 300x168px
Is anyone else extremely angry that notch ruined 0x10c and turned into a lazy fuckwad? I was really looking forward to 0x10c turning into something.

http://www.wired.co.uk/news/archive/2015-07/notch-net-worth-isolation-twitter-outburst

Years ago, back when Minecraft was new and I was a kid, he was my idol. I wanted to be more like him. Then as time passed, I grew to understand him more - I started realizing how lazy he was, barring necessity - and how similar our personalities were in that regard. That was a problem, so I got off my lazy ass and started doing shit.

It still makes me angry.
>>
>>52332310
char *pc;
int *pi;
double *pd;
>>
>>52332310
Give her the dick
>>
>>52332338
It's hard to create something if you don't have a clear vision of what you want it to become. As seen in the vids of the game.
>>
>>52332310
Watch Oreimo with her
>>
>>52332361
Haven't you noticed though? It was never just 0x10c. The trend of slowing Minecraft updates long before the sell to Microsoft, the failed promises on the modding API, him stepping down as lead of Minecraft, the fact that he's personally created nothing even remotely major since he gained high income/savings, etc.
>>
>>52332310
Posting your code and what you are trying to would help (make sure to put it in code tags "
" "
").

>>52332339
lol
>>
>>52332338
fat == lazy

In one way or another
>>
>>52332353
>>52332368
I'm not a guy and even if I was that's gross.
>>
>>52332323

Yeah, didn't want to type out the entire question to just get called newfag or whatever is trending on 4chan these days.

Anyway, fuck it. I'm writing a program in java to read in data from a text file. The text file has 2 columns and unknown number of rows. The first column contains integer values and the second column contains what's called CPT codes. I just read those in as strings. Thing is, the integers in the first column can be any number. For example, the text file I am using to write the program has 11185 rows and the values in column 1 range from 1 to 8000. The CPT codes need to be printed together depending on the first column value (CPTs with value 1 are printed together, CPTs with value 2 printed together, CPTs with value 167 printed together, etc). What do I need to use to try and keep these CPT codes together based on the value in the first column? A simple array doesn't work obviously. Do i need to use some sort of HashMap? Or a multidimensional array? Again, I'm new to programming, so the answer might be obvious to some.
>>
>>52332487
Fuck me I didn't think that one through
>>
>>52332495
this is 4chan you aint seen nothing yet
>>
>>52332338
many people are fuckwads

like peter molyneux

but don't let that bring you down... let it inspire you to do even better
>>
I'm trying to use go-python to compile a golang library to be usable in python. However when I try to return a byte array/byte slice (I don't actually know which it is I don't know shit about golang)
I get errors:
./dviza.c: In function ‘cpy_func_0x359372799_item’:
./dviza.c:424:9: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
pyitem = (&item);
^
cc1: warning: function may return address of local variable [-Wreturn-local-addr]
./dviza.c:423:10: note: declared here
GoUint8 item = cgo_func_0x359372799_item(self->cgopy, i);
^


If I'm not trying to pass a byte array everything compiles fine, but I need to pass that shit for use in python.
>>
>>52332495
Damn, this clip will have to do then

https://www.youtube.com/watch?v=9B4lvRueoEY
>>
File: idea-man.jpg (25KB, 499x372px) Image search: [Google]
idea-man.jpg
25KB, 499x372px
I just made a FizzBuzz in Assembly

Am I a Software Engineer now?
>>
>>52332504
just use two vectors
vector<int> rowOne;
vector<string> rowTwo;


>>
I'm writing a network monitoring system.
Unfortunately, not all devices support SNMP, so I have to work around that.
I've written an interface for SNMP, CIsco SG200's web interface, and UPnP IGD.
Now the data has to be periodically collected and put in a time series database.
>>
>>52332584
It's java, so he'd want ArrayLists
>>
>>52332557
post code or it didn't happen
>>
>>52332557
Could you show us the code?

Did you use libc? Or syscalls directly?
>>
How do we get women and pajeets out of coding?
>>
>>52332651
use functional languages only
>>
File: dpt.png (2MB, 1696x2467px) Image search: [Google]
dpt.png
2MB, 1696x2467px
>>52332651
We fill the quotas using girls that have XY chromosomes
>>
>>52332651
why do we want women out of coding?
>>
>>52332708
found the cuck

but seriously I think that guy is just trying to be edgy
>>
>>52332504
I haven't written in Java for a while but you could make a HashMap that has the int value as the key and an ArrayList of your CPT codes as the value.
>read file
>put int values and empty arraylists into map
>go through it again
>get corresponding arraylist using int value as key
>put CPT code into list

then when you want to print them you just look up the ArrayList using the int value and print the list
>>
>>52332504
HashMap<Integer, String> map = new HashMap<Integer, String>();

Files.lines(Paths.get(filename)).forEach(s -> {
String[] columns = s.split('\t');
map.put(Integer.parseInt(columns[0]), columns[1]);
});


Assuming the columns are separated by a tab, something like this.
>>
>>52332697
>tfw XY girl but can't even get into uni

I'll never be a real coder ;_;
>>
Best languages for project euler?
>>
>>52332749
From the sounds of it, there are multiple codes associated with each value. This would overwrite the codes.
>>
>>52332651
lock the office doors so the curries can't shit on the sidewalk and add asperine to all coffee and tea so women literally have to go home 1 week a month because they bleed to much out of their asscrack.
>>
>>52332797
Whatever language you know and want to get better at.
>>
>>52332797
Haskell. No really, if you start using it you'll see how amazing it is

My solution for project euler #31 is only 6 small lines

>>52332769
Damn, that sucks. What country do you live in? I don't know anyone here that says "uni".
>>
>>52332797
haskell

>inb4 everyone else is wrong
>>
>>52332797
Not python. It's my main language, but even with the best algorithms I can think of, it shows its lack of speed quite well. I'd say something like C
>>
File: enem-logo.jpg (335KB, 1619x1040px) Image search: [Google]
enem-logo.jpg
335KB, 1619x1040px
Yesterday the ENEM (Brazilian SAT) results came out and I think I have enough grade for a Computer Engineering degree at a good university.

I got 770 on it, yay!!!

Who /ENEM/ here?
>>
>>52332869
>but even with the best algorithms I can think of, it shows its lack of speed quite well.
I have written a solution in python yet that take more than 2 seconds to complete. You must be doing somethign wrong.
>>
>>52332869
python, js, and pretty much all scripting languages are severly crippled when it comes to large calculation
>>
>>52332059
>using the ternary operator on statements
Can you do that?
>>
>>52332885
>BR
It's literally only you bub.
>>
>>52332898
>2 seconds

that's slow as fuck m8
>>
File: underageb&.png (96KB, 1011x117px) Image search: [Google]
underageb&.png
96KB, 1011x117px
>>52332885
>>
>>52332940
But I'm 19 bro.
>>
>>52332885
Congratulations, probably better off posting in /int/ though if you want to discuss Brazil specific stuff.
>>
>>52332697
I fapped to that sauce.
>>
>>52332885
err good job m8
>>
>>52332808

correct. Out of the 11185 codes on the test .txt file I am using to write the program, 7699 of those codes have a value of 1, around 2000 have a value of 2 (I am looking at one CPT code which has a value of 405, the next value is 450 which has five or so CPTs associated with it). So, yes there are multiple codes associated with each value usually, but not necessarily always, it's completely random. Also, I need to check, but I don't think the CPT codes are unique (i.e. there may be a CPT code listed 2 or three times but with a different value each time)
>>
>>52332808
Oh I'm a complete derp, fixed.
HashMap<Integer, LinkedList<String>> map = new HashMap<Integer, LinkedList<String>>();

Files.lines(Paths.get(filename)).forEach(s -> {
String[] columns = s.split('\t');
Integer key = Integer.parseInt(columns[0]);
if (!map.containsKey(key)) {
map.put(key, new LinkedList<string>());
}
map.get(key).add(columns[1]);
});


>>52332857
England
>>
>>52332885
What percentile is that? I got 97.5th on my SATs (2 score).

>>52332901
JS beats Python by a lot in most benchmarks though

>>52332909
printf(...) is an expression like anything else. The function returns an int.

>>52332959
Me 2 breh it's a good one

>>52332982
Damn, you seem like university material to me easily. Idk why you got rejected. I live in the US though so idk how different it is
>>
>>52333014
Just looked up myself, apparently a 770 is above average for all the top schools in Brazil
>>
why does brainfuck even exist? it defeats the purpose of having a programming language in the first place

 >++++++++++[<++++++++++>-]<[>+>[-]>++++++++++[<++++++++++>-]<+<<[->>->+<<<]>>>
[-<<<+>>>]<>>+++<<[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>[-<+>]+>[-]>[<<->>[-]]>[-]
<<<[[-]++++++++++[>++++++++++<-]>++.+++.[-]<[-]+++++++++++[>+++++++++++<-]>+..
[-]<[-]<<[-]>>]<>>+++++<<[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>[-<+>]+>[-]>[<<->>[
-]]>[-]<<<[[-]+++++++++[>+++++++++++<-]>-.[-]<[-]+++++++++[>+++++++++++++<-]>.
+++++..[-]<[-]<<[-]>>]<<[[-]>>++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]>>[
>++++++++[<++++++>-]<.[-]]<>++++++++[<++++++>-]<.[-]<<<]>[-]++++++++++.[-]<[-]
<-]
>>
>>52331760
> cout was in C++ before C++11
> cout doesn't use variadic arguments with diverse types
> anon doesn't see the logic
>>
File: 1452279387266.gif (276KB, 240x287px) Image search: [Google]
1452279387266.gif
276KB, 240x287px
>>52333083
AWW SHIT
>>
>>52333083
>it defeats the purpose of having a programming language in the first place

it's an esoteric language, that's the point
>>
>>52333083
It's all in the name m8
>>
>>52333083
it's designed to put to end arguments involving how code looks or how one code is more superior to another based purely on aesthetics or how it looks and "beautiful code"
the only comparisons to be made between code are objective, everything else is irrelevent
>>
>>52333014
Bad grades
>>
>>52333087
> cout doesn't use variadic arguments with diverse types
Well didn't think about that.
But still it could be just macro to call toString method on class or print it's memory address and for numbers print the value.

cout takes argument of any type.
so
cout << a << 4 << endl;
could as well be implement as cout(a, 4, endl);
>>
>>52332925
Actually turns out most of the stuff that ran over 2s was because I was shit at Python when I started. Just cut my time for problem 21 by a factor of 10 using a better algorithm for getting divisors.
>>
does autocomplete actually hurt unless you are professional doing his day job?
>>
>>52333180
>it's designed to put to end arguments involving how code looks or how one code is more superior to another based purely on aesthetics or how it looks and "beautiful code"

I'm pretty sure it was just a fun project to try and make a really small compiler but by all means, get gay about it
>>
>>52332959
>>52333014
Post it.
>>
>>52332885
BR literally the indians of America
>>
decided to buy an arm board, and use a scheme interpreter called armpit
currently getting it to flash the onboard led's
funfunfun
>>
Made some progress on my YouTube scraper. It's more license header than actual code.
Got a basic set up for the config and database. Next up will be sending emails and invoking commands. When that's done, I can finally start working on the scraper and wire everything together.
https://github.com/0xBA5/termtube
>>
>>52333220
no it helps you pretty much anywhere as long as you're using tab to complete
>>
>>52333281
>currently getting it to flash the onboard led's

way to go champ
>>
someone explain a screen scraper pls?
>>
>>52333279
So they are stealing jobs from americans?
>>
>>52333333
>>
File: Mv69Ele.jpg (119KB, 1152x2048px) Image search: [Google]
Mv69Ele.jpg
119KB, 1152x2048px
 
for i in range (1,101):
startslice = i*i%3*4 #All of these operators have the same precedence and so are evaluated from left to right.
endslice = 8--i**4%5 # 8--i is 8 minus negative i. ** is power.
#The order of operations puts Power first, then modulo, then subtraction.
output = "FizzBuzz"[startslice,endslice]
print output or i #"or" returns the first value that is True, empty strings are interpreted as being False. On the occurrences where startslice and endslice are the same output is an empty string.
>>
>>52333333
>>
>>52333359
>those comments
disgusting
>>
File: tZk9wdy.jpg (449KB, 1920x1080px) Image search: [Google]
tZk9wdy.jpg
449KB, 1920x1080px
>>52333453
just explaining...
>>
>>52333479
>explaining basic operations and precedence, but not why powers and modulo return what they do
>>
>>52333479
>8 - - i is 8 + i
great explanation. so why use both minus signs?
>>
>>52333508
you don't know what powers and modulo return? and you're making fun of me? kek
>>
>>52333539
I do, you dumb shit, I'm telling you have awful priorities
>>
File: ABORTION.png (203KB, 740x1024px)
ABORTION.png
203KB, 740x1024px
>>52333531
because "FizzBuzz"[4:8] , that's the part that slices "FizzBuzz" into two parts either "Fizz" if it's just [0:4] or "Buzz" if it's [4:8], it doesn't make any sense whatsoever for the second number to be larger than the actually len("FizzBuzz") which is 8


>>52333561
wow, someone isn't getting laid a lot lol...
>>
>yfw you catch a glimpse of c++ OOP
>>
>>52333609
Babe you know I don't document my code!
>>
>>52333609
>because "FizzBuzz"[4:8] , that's the part that slices "FizzBuzz" into two parts either "Fizz" if it's just [0:4] or "Buzz" if it's [4:8]
Either awful at explaining, or you have no clue how the operations affect the slicing
>>
>>52333609
you completely misunderstood the part I'm referring to and didn't answer my question at all. I don't think you understand why two minus signs are used.
>>
>>52333638
>>
File: 1427316895566.jpg (11KB, 258x195px) Image search: [Google]
1427316895566.jpg
11KB, 258x195px
>>52333638
>>
>>52333359
>Power first, then modulo, then subtraction
You missed an important one
>>
Can A* be implemented in this project?

https://drive.google.com/file/d/0B59QDb8bX_zqZTlwYkVYSmlOV2c/view?pref=2&pli=1
>>
File: 1449250621370.jpg (149KB, 1248x1024px) Image search: [Google]
1449250621370.jpg
149KB, 1248x1024px
>>52333671
8+i would give a number larger than 8 you imbecile, you don't need a number larger than 8, the part after 8 can either 1 nothing or 4, going from 0 to 7, so you end up with [0:8-1] = [0:7] >> means print the whole fucking word
>>
>>52333359
#The order of operations puts Power first

bullshit the unary negation operator comes first

go back to fizzbuzzing...oh wait
>>
I'm trying to bind directly to a data object but for some reason shit ain't having it.
<TextBox x:Name="txtNotifSec" Text="{Binding NotifSeconds}"/>


http://pastebin.com/AU3UBfdu

I set the value to "3" at runtime, I output it to console to check 100% that the value is correctly set.

But for some reason the textbox only ever shows "0" and everything I've tried results in either "0" or nothing at all.
>>
>>52333731
why are idiots always the most obnoxious.

it's quite clear you understand neither the code, the order of operation nor the simple question of why there two consecutive minus signs
>>
     for(int i=1; i<101; i++){
if (i%3==0 and i%5==0) cout << "fizzbuzz\n";
else if(i%3==0) cout << "fizz\n";
else if (i%5==0) cout << "buzz\n";
else cout << i << "\n";
}
>>
>>52333731
I'd give her the capitalist D
>>
>>52333731
You're a fucking idiot

The algorithm never ends up at [0:7] (which isn't the whole word, it's FizzBuz)

The slicing either gives you [0:4],[4:8] or [4:4], the latter of which is an empty string, which evaluates to False and prints the number instead

Don't explain shit you don't know
>>
>>52333728
anyone??
>>
>>52333784
Forgot to add the slicing can also give you [0:8]
>>
>>52333731
8 - ( - i ) == 8 + i
>>
File: Laughing-women.jpg (2MB, 1132x1696px)
Laughing-women.jpg
2MB, 1132x1696px
>>52333732
>he doesn't even know how Python treats modules of negative numbers taken to a power


>>52333773
Oh god.. you're mentally deficient, do you know that?
>>
Can anyone recommend a full software engineering course online?
>>
>>52333754
And yes I tried setting "TargetNullValue=''"

But that's not helped either.
>>
>>52333728
>>52333803
What kind of mega-hipster language is A*?
>>
>>52333816
This is coming from the same guy who thinks [0:7] prints the whole word lmao. If you sincerely believe everything you've said, and you don't understand the precedence of the unary operator, you're an idiot. Otherwise, you're trolling
>>
>>52333828
A* is an algorithm, you stupid fuck.
>>
>>52333323
progress is progress lol
I would have thought /g/ would have more of a presence for such stuff, like arduinos and that, or has the hype died down to the point where I'd have to start a thread and people will crawl to it?
>>
>>52333775
optimize it nigz
>>
>>52333828
it's actually an algorithm used by your mothers blood cells to find a route around all the blocked arteries back to her heart
>>
File: 1449255745612.jpg (10KB, 250x213px) Image search: [Google]
1449255745612.jpg
10KB, 250x213px
>>52333784
>>The algorithm never ends up at [0:7] (which isn't the whole word, it's FizzBuz)


Are you retarded?

I was explaining to him how slicing works not how it works in this example. It starts at 0 you fucking moron, it ends on 7. That's a full word "FizzBuzz". I can take the screenshot of my console right now if you want!


kek, on another note Cunningham's Law is working fine...so so fine.. tnx a lot guys, asked a friend he didn't know how it works, found a thread on stack, still nothing but /g/ delivers every time!
>>
>>52333843
>>52333861
Calm your dicks lads
>>
>>52333861
for(int i=1; i<101; i++){
if (i%15) cout << "fizzbuzz\n";
else if(i%3==0) cout << "fizz\n";
else if (i%5==0) cout << "buzz\n";
else cout << i << "\n";
}
>>
File: TDgUdWW.png (278KB, 4799x2701px)
TDgUdWW.png
278KB, 4799x2701px
>>52333359
Guys, I got it below the syntactic level.

For some reason, (i**2)%3 is always 1 when i isn't a multiple of 3, never 2, which could perfectly happen at first glance, but that's some arcane number theory or what.
For some reason, the same is true of (i**4)%5.
Then, I found out empirically that 8--i**4%5 is equivalent to 8-(-i**4)%5. Given that i**4%5 is either zero or one, (-i**4)%5 will be 0 or 4, which is an useful coincidence, since we need that exact value for the second pivot.

This is too much, Geffrey, it can't be a coincidence! Think about it, the illuminati ramped up the whole formulation of FizzBuzz 50 years ago, so that one of them could "discover" this "trick" now and destroy the old world order! They are already here, and Guido is one of them! Fucking Reptilians
>>
>>52333904
>Complaining about hostility on 4chan
I think you should kill yourself
>>
File: idiot.jpg (8KB, 175x86px)
idiot.jpg
8KB, 175x86px
>>52333881
>trying to use "pretending" as a defense against your own idiocy
Nice try
>>
r8 my fizzbuzz

#include <iostream>

template <int n, int m3, int m5>
struct fizzbuzz : fizzbuzz<n-1, (n-1)%3, (n-1)%5>
{
fizzbuzz()
{ std::cout << n << std::endl; }
};

template <int n>
struct fizzbuzz<n, 0, 0> : fizzbuzz<n-1, (n-1)%3, (n-1)%5>
{
fizzbuzz()
{ std::cout << "FizzBuzz" << std::endl; }
};

template <int n, int p>
struct fizzbuzz<n, 0, p> : fizzbuzz<n-1, (n-1)%3, (n-1)%5>
{
fizzbuzz()
{ std::cout << "Fizz" << std::endl; }
};

template <int n, int p>
struct fizzbuzz<n, p, 0> : fizzbuzz<n-1, (n-1)%3, (n-1)%5>
{
fizzbuzz()
{ std::cout << "Buzz" << std::endl; }
};

template <>
struct fizzbuzz<0,0,0>
{
fizzbuzz()
{ std::cout << 0 << std::endl; }
};

template <int n>
struct fb_run
{
fizzbuzz<n, n%3, n%5> fb;
};

int main()
{
fb_run<100> fb;
return 0;
}
>>
>>52333917
No thanks, I'm fine
>>
File: pong.jpg (136KB, 750x500px) Image search: [Google]
pong.jpg
136KB, 750x500px
>>52333847
I was just fucking with you, that's good. Most people are too scared to go with anything other than Arduino. People talk about embedded stuff every now and then, but it's usually dumb shit like fizzbuzz with LEDs. I'm waiting on an adafruit order and then I'll be working on a project or two so I might post it here.
>>
>>52333911
The fuck are you idiots on? We figured this shit out ages ago

Are the people trying to explain it new?
>>
>>52333946
what screen is that anon?
>>
File: 1449225181224.jpg (96KB, 640x640px)
1449225181224.jpg
96KB, 640x640px
>>52333929
>pretending?

wat, I'm saying I didn't know it, I wanted someone to explain it to me better
I even asked before in this thread for someone to explain it, all answers were shit.
>>
File: 1376182921994.jpg (65KB, 445x488px) Image search: [Google]
1376182921994.jpg
65KB, 445x488px
>>52333930
>Sepplesfags will defend this
>>
>>52333963
https://www.adafruit.com/products/250

there's a negative one too
>>
Why do people always feel the need to create classes for things that can be easily solved with functions?
>>
How do I share code I've written between multiple android studio projects?
Right now it's a package inside one of my projects.
>>
>>52333978
I'm gonna throw you a bone

Next time you need an explanation for something simple, google it or use python shell to test shit out

Here's the page with python operators precedence, it's at the bottom: https://docs.python.org/2/reference/expressions.html

Following those tips will help you in the future, in regards to your projects and not looking like a goddamn idiot
>>
>>52334002
OOPfags
>>
>>52334017
i did google it, the code I posted was from reddit...

you've been taken for a ride my friendo!
>>
>>52333202
That's a shame. I didn't get into my goal college because of my grades, but it turns out my SATs managed to save me a seat at my fallback school.

I hope things turn out okay for you, too. College/uni isn't everything.
>>
>>52334002
OOP vs functional literally
>>
>>52334017
why?

he's clearly just a really thick troll intent on acting out the "hurr pretending to be retarded so that I can get people to call me stupid" meme comic
>>
>>52334050
It just makes no fucking sense to create a class that stores only a single variable.
And yet people do it.
>>
>>52334083
planning for the future m8
>>
>>52333479
I liked your comments, anon.
>>
File: goldstein.jpg (1MB, 1425x1796px) Image search: [Google]
goldstein.jpg
1MB, 1425x1796px
>>52333951
What part are you talking about? The conspiracy theory one or the number theory one? In the former case, you deserve to die since you're redpilled and you do nothing. In the second case, note that no one demonstrated an understanding of that before my post, so thanks for being so receptive to intellectuals proletarian jackass.
>>
>>52334083
this tbqf
>>52334104
You need to have good reason for having a variable floating about
>>
>>52333930
I don't know why this works
>>
>>52331917
Is pic related "Project Euler?"

If so, then yes, Project Euler is absolutely worth doing.
>>
>>52334083
That's one thing I don't like about Java, the fact that everything has to be inside a class and you can't just create free-floating functions.
>>
>>52331284
Monads are just monoids in the category of endofuntors.

But in reality they're just a context.
>>
>>52333946
yh, I'm going with the stm32f4 discover board
it's a learning process, as I have no knowledge of hardware engineering or electronic engineering so doing substantial stuff is learning from the ground up, but it's fun
>>
>>52334114
It was the second case
>no one demonstrated an understanding of that before my post
If you're talking about negative modulos, we all knew that
If you're talking about binomial expansion, which explains i*i%3 being 0 or 1, or i**4%5 being 0 or 1, we all knew that

Is there some other number theory bit you thought none of us knew?
>>
>>52334083
It's required by some languages. C# and Java come to mind. That's something I like about C++ is you can ignore OOP for small shit.
>>
>>52332339
Was waiting for this.
>>
>>52332651
Stick to low level languages and you shouldn't meet too many.

The moment you go Java your co-workers will be Rajesh and Ranjeet. The moment you go Python your co-workers will be Stacy and Emily.
>>
>>52334104
>planning for the future
Worst idea ever.
If your plans change, you will have wasted your time writing code you can't reuse.

Better break everything up into tiny functions that do only one thing, then you'll have lots of reusable code for later.
>>
>>52334154
It's not too hard, being a good programmer is more important than electronics/hardware knowledge anyway. Treat the datasheet like your bible and it's just a matter of chipping away at it.
>>
>>52334124
>You need to have good reason for having a variable floating about

What are you talking about? It's more like you need a good reason for having a class.
>>
>>52333828
A* is an algorithm that finds the shortest path between two points when there are obstacles in the way.
>>
How does OpenGL treat scope when doing stuff like compiling shaders and binding objects?
I'm guessing it doesn't give a fuck, so you can just copy the handle outside the function and keep using it?
>>
>>52334174
not very good for DRY tbqh

let's say you write a function to calculate the sum of n numbers. if you wrap it in a class it's easy to extend to integers, floats and doubles whereas a single function would need to be copy pasted
>>
>>52334231
>What are you talking about?
It's in plain english. The only other time you want variables floating about is because it's used only and contained within a certain file, and at that point, it's pretty much a class. If you have this variable floating about that you call from elsewhere, you can't really describe its context, why it's in that specific place and it'll be more difficult debugging trying to keep track of where these mystery variables are located
>>
File: trig.gif (3MB, 961x491px) Image search: [Google]
trig.gif
3MB, 961x491px
>>
>>52334285
>a single function would need to be copy pasted
>what is parametric polymorphism
>>
>>52334290
type Point = (Int, Int)

add (x1, y1) (x2, y2) = (x1 + x2, y1 + y2)


The context is the function itself. Why would you make a class for Point when you can just do something as simple as this?
>>
>>52334321
you mean generics?

they're cool I guess, but it's a bit of a mess without a consistent interface in which case it's pretty much the same thing as polymorphism
>>
>>52334319
in python

 import math,time
msg = 'OSGTP !!Ju67JuF6jBe sucks dick+++++++++'
freq = 0.01
amplitude = 40
speed= 0.02
i = 0
while True:
s= amplitude*(math.sin(2*math.pi*freq*i)+1)
print(int(s)*' ' +msg)
msg = msg[1:]+msg[0]
time.sleep(speed)
i+= 1
>>
>>52334249
> How does OpenGL treat scope when doing stuff like compiling shaders and binding objects?
Er, what?

> I'm guessing it doesn't give a fuck, so you can just copy the handle outside the function and keep using it?
Object "names" (i.e. handles, unsigned integers returned from glGen* or glCreate*) are either unique within a single context or within a group of contexts which share data.

Other than that, they're not "scoped". All state that's not part of a container object (e.g. VAO or FBO) is part of the context. So if you only have one context, it's effectively global.
>>
>>52334360
I think you misunderstood my post, or thought I was the guy talking about functions when the initial complaint was classes with 1 variable.

In your instance, there is no variable floating about, you've defined a type and a function for it
>>
>>52334321
>parametric polymorphism
"parametricity" means you can't do anything with it, like void*
Too bad people misuse 9-syllable phrases to sound smart.
>>
>>52334360
Because not all languages support functional constructs. What does the symbol 'add' refer to? Is it add point1 point2 or add int1 int2? Compare with Point.add v.s. Int.add, or even better: int1.add(int2) and point1.add(point2). The latter is also a lot less verbose and also allows you to define safely int1.add(point1) and point1.add(int1) if you want.
>>
>>52334425
>I have no idea what I'm saying but I'm sure I sound smart by calling someone else stupid!
>>
>>52333823
Sorry for a shitty /r/-tier post.

I couldn't go to college because reasons (let's not get into that). I currently run a small web design company with my bro and it's not great but I make a living.

I have spend more time doing projects than learning programming and software theory. I complete projects every month and my clients are happy, most of the time, but I am not.The way I do things it's ugly, not scalable, fragile and amateur and I never feel proud when I finish a project because I know if some other programmer laid eyes on it they will be cursing me.

S, long story short, is there a curriculum for software engineering that I can follow so I have the sufficient knowledge of software design and architecture as a college graduate? Are there any good online video courses? What are my options.
>>
>>52334455
udacity's nanodegrees
>>
I've now managed to really figure out observational type theory and how to make it work in my language. I still have to work out the implementation details, though.

The main feature of the type theory is heterogeneous equality, and a couple of special ways to work with it.
coe : a == b -> a -> b

ap{F : a -> b} : x == x' -> F x == F x'


You can then trivially define, for example, the
transport
function, commonly seen in homotopy type theory, which "transports" a proof along an equality.
transport{F : a -> Type} : x == x' -> F x -> F x'
transport = coe . ap


"Quotient inductive types", which can introduce non-trivial equalities (paths), can be defined. They are a limited form of higher inductive types, as they cannot introduce higher order equalities (homotopies).
data Interval : Type where
Zero : Interval
One : Interval
Segment : Zero == One


The most interesting thing that I discovered was how to define recursive functions over quotient inductive types as a simple extension of regular pattern matching, as shown by this generic induction principle.
interval{F : Interval -> Type} : (zero : F Zero) -> (one : F One) -> transport{F} Segment zero == one -> (x : Interval) -> F x
interval zero _ _ Zero = zero
interval _ one _ One = one
ap{interval _ _ segment} Segment = segment


The great thing about this formulation of equality is that it should still respect proof irrelevance, which means that equality proofs are purely used at compile time and may be erased when the program is compiled.
>>
>>52334425
another valid point

to make meaningful use of parametric types in functions mean that they have to conform to the specific interface used in your function. and if you're using a specific interface why not abstract that into a class and subclass which makes everything a lot clearer.
>>
>>52334360
There are a couple of reasons for making it a distinct type.

One is because there are a lot of things which a pair of Ints could be used for. Having a distinct type means that passing some random pair of Ints that doesn't actually represent a point (e.g. because you go the (x,y) and (lo,hi) arguments the wrong way around) will generate a error.

Another is that it allows you to change the details of the type later without having to change anything which merely references the type (e.g. a structure containing an instance, or a function which simply passes a point value through to some other function).

Another is that it improves the documentation value of the function's signature, or error messages ("expecting Point" is more precise than "expecting (Int, Int)").

This applies even if the type contains a single scalar quantity. It can be used e.g. to prevent you from adding some number of metres to some number of seconds.
>>
>>52334419
Would you mind giving an example of a floating variable then?

>>52334429
>Is it add point1 point2 or add int1 int2
It's obvious from the type, Point -> Point -> Point.
>>
>>52334455
Hi, I'm not in your situation exactly since I'm actually going to college now, but I actually was a self taught programmer to beyond the college level well before I turned 18.

A lot of my learning resources are kind of outdated compared to all the fancy web-based stuff that exists today, so I don't know if my advice in that area would be helpful.

But I do want to say this: don't give up. You absolutely can get a college education out of self-teaching and be more employable than most college graduates while you do it.

I wish I had more knowledge about the best modern tutorials these days, but I just really want to say that I've been there feeling stuck without a real class to help me and there absolutely is hope. If you have any questions as you go along I'll be around DPT for at least the next few days.
>>
>>52334455
> way I do things it's ugly, not scalable, fragile and amateur and I never feel proud when I finish a project because I know if some other programmer laid eyes on it they will be cursing me.
Welcome to web development.

Seriously, the environment doesn't favour Doing It Right. It favours Doing It Right Now, lowest-bidder wins, etc.

If you improve your skills, you may write better code, but you probably won't get paid any more and your clients probably won't be noticeably happier. You'll probably be even less proud of the junk that you're forced to create because you're having to compete with typical "web developers" (i.e. someone whose entire programming knowledge extends to the first 3 chapters of "learn PHP in 5 minutes" and went into web development because they can do most of it from their mom's basement).
>>
>>52334394
it's cool but that code looks like shit
>>
>>52333775

This might sound silly, but instead of using modulo 3 and 5, could you not just use modulo 15 since any number that is a factor of both 3 and 5 is a factor of 15?
>>
i'm bored. you're all boring
>>
>>52334623
I'm not sure what type of web dev you do, but the reason why so many frameworks and libraries exist is because people want to and are trying to do it right - but everyone has a different opinion about how to do it.

This is multiplied by the mess that was raw HTML/JS (especially so in the past) and the fact that new features come out all the time that make past libraries partially obsolete.

In freelance work this might not be as noticeable, but if you work for a real company on an internal project or a startup that actually hired well, people generally stick to some methodology that's often strongly associated with the framework/stack they're using.
>>
>>52334682
>could you not just use modulo 15 since any number that is a factor of both 3 and 5 is a factor of 15?
Yes, that is correct.
>>
I always get so paranoid about whether to pass a pointer or a value, it probably doesn't matter much but I keep worrying about the possible side effects of that decision.
>>
>>52334083

Easier to understand since it forces everything to be encapsulated as an object, makes it easier to implement future changes without getting segfaults


Really though its a question of taste / context. I dont think embedded systems would accept the overhead required
>>
>>52334700
What do you want to talk about, anon?
>>
Help me find a job
>>
>>52334623
>you probably won't get paid any more and your clients probably won't be noticeably happier
That is not entirely my goal. Clients are never happy and I don't want to learn to get paid more.

I need all the theory because I have started working on a personal project and I want to do it right. I have already started learning database design and I feel enlightened already. I just find a good course or book for software design and architecture.
>>
>>52334820
I have a job in my pants you could help me with :^)
>>
Object Pascal doesn't deserve to be so obscure, it fills a very nice niche that people keep using the wrong programming languages for ;_;
>>
>>52334820
found your mother a job last night
>>
I learned C++ in 2005. Apparently it was C++ 98 and C++ 03, 11, and 14 have come out. I haven't used it since about 2010 and I haven't heard of these new standards until a couple weeks ago.

How useful is my 98 knowledge now? Does C++ still let you get close to the hardware if you want to? What do you see as the major benefits of these new standards? Does gcc and visual studio support these new standards?
>>
I'm making a task/to-do list management application for Windows using C#

Just finished all the basic functionality, the ability to add tasks, complete them, little notification displaying the completed task and what your next task is, all that nice stuff.

What features would be useful? If I can actually get around to finishing this and making it robust and workable it'd be cool if people might actually use it.

It already stores tasks (both existing ones and completed ones) and has stuff like when the task was added, when it was completed, etc. etc.
>>
>>52334740
If the parameter isn't modified and is small and/or likely to be a literal, pass by value. If the parameter isn't modified but is larger, pass by const pointer. If the parameter needs to be modified, pass by pointer.
>>
>>52334843
>>52334864

Faggots
>>
>>52334704

Phew, okay, Im NOT an idiot

Also if Im understanding OP fizzbuzz right, basically its a one line wonder that checks if its divisible by 3 or 5 and splits the 8 character string accordingly? I cant into python so all those operators are gobblygook

I understand the theory, but the practice eludes me
>>
>>52334797
poo poo pee pee
>>
>>52334870
new C++s have functional programming now, so it's useful-ish again
>>
>>52334870
https://www.youtube.com/watch?v=xnqTKD8uD64

This is probably the best way to get up to speed. It's worth the watch.
>>
>>52334704

I wonder what order of magnitude it is more efficient to use n%15 over n%3&5
>>
>>52334870
>How useful is my 98 knowledge now?
Very

>Does C++ still let you get close to the hardware if you want to?
Nothing about the ability of the language was removed. 11 just makes it 3x easier to program and more efficient. Fixing problems. 14 fixes more problems.

>What do you see as the major benefits of these new standards?
Just learn about auto and range-based for-loop. Those are easily the most useful about 11.

>Does gcc and visual studio support these new standards?
AFAIK GCC 4.8.2 was the first full implementation of C++11. VS's support is still poor; lagging behind like IE. GCC has tables for these:
https://gcc.gnu.org/projects/cxx1y.html

How could you possibly be so slow? C++17 is the upcoming thing now. Post-11 is considered 'Modern C++'
>>
>>52335006
If the compiler can optimise for a shit, probably none.
For an interpreted language, probably a little. Less shit to parse and one less calculation.
>>
>>52332537
tfw you will never be an onee-chan with a cute imouto
>>
>>52334948
>splits the 8 character string accordingly?
Yes

If it's divisible by 3, the slice will be [0:?], otherwise it'll be [4:?]

If it's divisible by 5, the slice will be [?:8], otherwise it'll be [?:4]

so divisible by 3 only would be [0:4] or "Fizz"
5 only would be [4:8] or "Buzz"
3 and 5 would be [0:8] or "FizzBuzz"
neither would be [4:4] or ""

For [4:4], given how "or" works in python, because the first argument is False ("" evaluates to False), it prints the second argument, even if that is also 0 or ""
>>
>>52334551
How do you know the type if you're in the middle of a file? Protip: you literally can't.
>>
File: lel.webm (13KB, 202x50px) Image search: [Google]
lel.webm
13KB, 202x50px
>>
>>52335123
wew
>>
>>52335028
>VS's support is still poor
VS2013 had garbage support, but VS2015 has full C++11 support (maybe one or two things it doesn't support, I can't remember exactly) and supports most of C++14
>>
>>52333083
The point of a language is portability, not to have a layer of abstraction to hide the complexity of assembly instruction. If you had to write brainfuck code differently for every CPU architecture, it would defeat the purpose of having a programming language.
>>
>tfw waiting 20 minutes til the next day so I can commit to my github and maintain my streak so I can relax tomorrow
who else /cheeky/ here?
>>
>>52335154
Good to know. I don't use VS and didn't keep up on the status too much. So, modern VS has good support.
>>
>>52333220
Not unless you're trying to learn how to type
>>
>>52333083
>prints newlines AND ascii versions of numbers
What a tight piece of code
>>
>>52335113
Neither can you know the methods of a class. Just take 5 seconds to look it up you lazy shit, or use an IDE that tells you.
>>
>>52335154
It doesn't support SFINAE. That's a pretty significant dealbreaker.
>>
>>52335231
>I am retarded and nobody can stop me!
>>
>>52335247
Nice argument, faggot.
>>
rate muh fizzbuzz
#include <iostream>
#include <sstream>
#include <map>

#define START 1
#define END 100

int main()
{
std::map<int,std::string> rules;
rules[3] = "Fizz";
rules[5] = "Buzz";

std::ostringstream store;
for (int i = START; i < END; ++i)
{
std::string out = std::to_string(i);
store.str("");
for (auto itr : rules)
{
if (i%itr.first == 0)
{
store << itr.second;
}
}
if(!store.str().empty())
{
out = store.str();
}
std::cout << out << std::endl;
}
}
>>
Adapting https://www.ffmpeg.org/doxygen/trunk/transcode_aac_8c-example.html into a general-purpose library for transcoding audio. Basically, a couple of other projects of mine need to convert audio files, and right now they rely on executing ffmpeg/avconv, which sucks for several reasons.

I've managed to adapt the example code to accept arbitrary formats, codecs, and bit rates. Next, I need to change the code to use a less atrocious coding style and maybe refactor the methods a bit.

I want to make the API pretty simple (since that's the whole point of wrapping libav*). The client will pass read/write callback functions which supply/use the original/new data in buffers, calling something like

transcode(read_callback, write_callback, format_name, codec_name, bit_rate);
>>
>>52335350
 int main()
{
int i, f = 2, b = 4;

for ( i = 1 ; i <= 100 ; ++i, --f, --b )
{
if ( f && b ) { std::cout << i; }
if ( !f ) { std::cout << "Fizz"; f = 3; }
if ( !b ) { std::cout << "Buzz"; b = 5; }
std::cout << std::endl;
}

return 0;
}
>>
GCC vs LLVM???
>>
>>52335483
>compiler v.s. virtual machine???
>>
>>52335439
wot
>>
>>52335496
>>52335496
>>52335496
NEW
>>
tfw spent an hour writing useless boilerplate code that I'll provably discard a couple of days from now.
>>
>>52335350
1. Using compiler macros is bad; you should always prefer to use const globals instead of macros.
2. Defining constants is still hardcoding. You've hardcoded the start number, end number, and number-to-word mappings. The logic of the program should be in its own function.
3. The ostringstream is scoped to main, even though it could be scoped to the first loop. This would also mean that the store.str("") would be unnecessary.
4. Instead of all the string conversion you're doing, you could just do the stringstream part, then use a ternary operator to choose what to print:

std::ostringstream store;

for (auto itr: rules)
{
if (i%itr.first == 0)
{
store << itr.second;
}

const std::string out = store.str();

std::cout << out.empty() ? i : out << std::endl;
}

6. Since the meme here seems to be making fizzbuzz as modular as possible, it would make more sense to define a function which, given a mapping and a number, returned the corresponding string, at which point one could use C++'s wide support for iterators and mapping to loop over whichever values they liked.
>>
>>52335622
Whoops, that code sample should read:

std::ostringstream store;

for (auto itr: rules)
{
if (i%itr.first == 0)
{
store << itr.second;
}
}

const std::string out = store.str();

std::cout << out.empty() ? i : out << std::endl;
>>
>>52334664
>implying you can do better
>>
Any good alternatives to IDA Pro?
>>
>>52335686
Why did you delete your post?
>>
>>52335638
>>52335622
Good point. Thanks!
>>
>>52335706
You should take a look at radare2 - it's mostly CLI though. It doesn't do everything IDA does I believe (I haven't used IDA Pro) but it has some really cool stuff. Steep learning curve though. I just started messing with it recently.
>>
>>52335832
cool, gonna take a look.
>>
>>52335727
To post in the new thread so for a better chance at responses because I'm a fag
>>
>>52335706
ida pro is universal now. No reason not to use it really.
>>
>>52336038
It costs a lot of money and is proprietary
Thread posts: 323
Thread images: 35


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