[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 35
File: fizzbuzz of the christ.png (402 KB, 1024x768) Image search: [Google]
fizzbuzz of the christ.png
402 KB, 1024x768
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 (1 MB, 1041x2677) Image search: [Google]
OpenGL-ES-2_0-Reference-card.png
1 MB, 1041x2677
enginebabbies everyone

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

can't even get fucking tetris right

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

C.
>>
File: baka.jpg (55 KB, 555x720) Image search: [Google]
baka.jpg
55 KB, 555x720
>>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 (2 MB, 720x404) Image search: [Google]
3Rgtx3S.webm
2 MB, 720x404
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 (5 KB, 256x255) Image search: [Google]
lua.gif
5 KB, 256x255
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 (77 KB, 435x653) Image search: [Google]
1452026137949.jpg
77 KB, 435x653
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 (55 KB, 900x810) Image search: [Google]
1441895090211.jpg
55 KB, 900x810
>>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 (786 KB, 300x168) Image search: [Google]
guesswho.gif
786 KB, 300x168
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 (25 KB, 499x372) Image search: [Google]
idea-man.jpg
25 KB, 499x372
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 (2 MB, 1696x2467) Image search: [Google]
dpt.png
2 MB, 1696x2467
>>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 (335 KB, 1619x1040) Image search: [Google]
enem-logo.jpg
335 KB, 1619x1040
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 (96 KB, 1011x117) Image search: [Google]
underageb&.png
96 KB, 1011x117
>>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 (276 KB, 240x287) Image search: [Google]
1452279387266.gif
276 KB, 240x287
>>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 (119 KB, 1152x2048) Image search: [Google]
Mv69Ele.jpg
119 KB, 1152x2048
 
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 (449 KB, 1920x1080) Image search: [Google]
tZk9wdy.jpg
449 KB, 1920x1080
>>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 (203 KB, 740x1024) Image search: [Google]
ABORTION.png
203 KB, 740x1024
>>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.
>>
File: 16286409295_ffda04216e_o.gif (469 KB, 480x228) Image search: [Google]
16286409295_ffda04216e_o.gif
469 KB, 480x228
>>52333638
>>
File: 1427316895566.jpg (11 KB, 258x195) Image search: [Google]
1427316895566.jpg
11 KB, 258x195
>>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 (149 KB, 1248x1024) Image search: [Google]
1449250621370.jpg
149 KB, 1248x1024
>>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 (2 MB, 1132x1696) Image search: [Google]
Laughing-women.jpg
2 MB, 1132x1696
>>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?
>>
File: 2050611763_649ff6bb8c (1).jpg (118 KB, 500x400) Image search: [Google]
2050611763_649ff6bb8c (1).jpg
118 KB, 500x400
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 (10 KB, 250x213) Image search: [Google]
1449255745612.jpg
10 KB, 250x213
>>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 (278 KB, 4799x2701) Image search: [Google]
TDgUdWW.png
278 KB, 4799x2701
>>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 (8 KB, 175x86) Image search: [Google]
idiot.jpg
8 KB, 175x86
>>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 (136 KB, 750x500) Image search: [Google]
pong.jpg
136 KB, 750x500
>>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 (96 KB, 640x640) Image search: [Google]
1449225181224.jpg
96 KB, 640x640
>>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 (65 KB, 445x488) Image search: [Google]
1376182921994.jpg
65 KB, 445x488
>>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 (1 MB, 1425x1796) Image search: [Google]
goldstein.jpg
1 MB, 1425x1796
>>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 (3 MB, 961x491) Image search: [Google]
trig.gif
3 MB, 961x491
>>
>>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.
Thread replies: 255
Thread images: 35

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.