[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: 321
Thread images: 48

File: 1493265566045.jpg (40KB, 625x469px) Image search: [Google]
1493265566045.jpg
40KB, 625x469px
Previous thread: >>60101975

What are you working on, /g/?
>>
First for C.
>>
Pycharm is bloated for the same serious Norton or McAfee is bloated. They are filled with shit so they can sell it to you.
>>
Third for marbles, slides, strings, levers, weights, and whacky household items.
>>
I ignore experience with Python that people put on their resumes
>>
File: 1483721177622.png (94KB, 396x395px) Image search: [Google]
1483721177622.png
94KB, 396x395px
>>60107254
>function
>that prints out
What did you mean by this?
>>
File: akari!!.jpg (83KB, 575x720px) Image search: [Google]
akari!!.jpg
83KB, 575x720px
Daily Programming Challenge!

Write a program that prints out the sum of the first 2 million perfect square numbers!
>>
Rust shills need to die and stop promoting social justice
>>
haskell is a joke
>>
>>60107221
Messing around with neural nets in tenserflow. Kinda wish I could afford to rent a server that could crawl larger data sets to do something more interesting with them.
>>
>>60107299
Not programming.
>>>/g/wdg/
>>
>>60107309
writing programs is programming
>>
>>60107221
Trying to wrap my head our the js ecosystem. Need to get babel + webpack + react + electron build working.

It's pretty overwhelming. especially when all the tutorials are already out of date after a few months.
>>
>>60107327
Wrong thread, fuck off back to >>>/g/wdg/
>>
>>60107327
>electron
Don't. Electron is morally wrong.
>>
>>60107299
FAG
>>60107327
EVEN WORSE FAG
>>
>>60107333
Javascript is programming :)
>>
Is learning MIPS architecture relevant in current year?
>>
>all these autists redirecting people to other threads and having a little baby tantrum

Go take your meds.
>>
Interesting video about types: https://www.youtube.com/watch?v=3U3lV5VPmOU
>>
@60107355
It's not. Your kind needs to fuck off.
>>
File: meme_girl_presents.png (142KB, 473x462px) Image search: [Google]
meme_girl_presents.png
142KB, 473x462px
>>60107254
print (2 * n^3 + 3 * n^2 + n) / 6

>>60107273
>define gcd(a,b)
>define Mobius function mu(x) by summing over all elements of order k of the n-cyclotomic field where gcd(k,n) = 1
>sum over all numbers x less than N such that mu(x) = 0
>>
>>60107336
I have to. Client requested this as both a webapp + desktop app. Easiest way is just to refactor the current webapp into electron.

>>60107344
Please calm yourself
>>
>>60107359
Did somebody say this?
>>
>>60107373
Do it properly or drop the client. A quick payout now is not worth your eternal soul.
>>
>>60107373
>working joe
>talks about clients
>web used in a sentence

Get out, /dpt/ is for autists and neets only.
>>
File: 1491299243518.jpg (38KB, 362x346px) Image search: [Google]
1491299243518.jpg
38KB, 362x346px
>>60107362
Isn't this video using Haskell? What does it have to do with "types"?
>>
>>60107356
not at all
>>
what to read to learn about this stuff?
>>60098940
>>
>>60107388
He goes on to use Agda later.
>>
>>60107381
It's not a large app at all, so I'm not too worried about having to maintain a huge amount code.

Have you developed with electron before? What were the pain points?

>>60107383
You get out, normie ;)
>>
>>60107389
Then why is it so popular?
What's the way to go instead?
>>
>>60107402
>;)
Your kind is not welcome here.
Also, why the hell do you space your posts like that, redditor?
>>
File: 1405877684107.jpg (61KB, 666x632px) Image search: [Google]
1405877684107.jpg
61KB, 666x632px
>>60107402
MOTHERFUCKER DID YOU JUST WINKY FACE AT ME
>>
>>60107414

What spaces?


:^)
>>
>>60107413
>Then why is it so popular?
maybe in school because it's simple and easy to learn but not in the real world
>>
>>60107402
>It's not a large app at all
And it was just one little apple that damned humanity for all eternity.
>>
>>60107420
>:^)
I don't want reddit stink nearby. Fuck off.
>>
@60107402
>"""developed"""
>electron
>>>/g/wdg/
>>
>>60107428
Then it's good as baby's first steps in microprocessor architecture?
>>
>>60107464
yes
>>
>>60107418
deserves a lol
>>
File: question 2.png (129KB, 314x278px) Image search: [Google]
question 2.png
129KB, 314x278px
My teacher said using static classes / methods / variables is as bad as using global classes / methods / variables and they are an anti-pattern.

Is this true? If you have a class you're certain you won't have multiple instances of why can't you set it to static?
>>
>>60107309
>>60107333
>>60107336
>>60107344
>>60107364
>>60107383
>>60107414
>>60107418
>>60107432
>>60107448
this thread is off to a great start
>>
>>60107518
Your teacher is simplifying things.
>>
>>60107518
statefulness in general should be avoided if it reasonably can. and that's what static means, it means the variables stay alive
>>
>>60107518
they should almost always be avoided
>>
>>60107518
>classes / methods
Wrong thread.
>>
>>60107518
>>60107544
>>60107551
Want to hear a sad story?
The codebase at work is almost entirely composed of static classes.
Coworkers question if you use a non-static class/method...like its abnormal to write code that is "Object Oriented" with an OO language...
>>
>>60107568
>The codebase at work is almost entirely composed of classes.
Sad story indeed.
>>
>>60107568
That's because OOP is trash.

Write and use referentially transparent functions as much as possible.
>>
>>60107568
lol they sound like C tards who were cucked into using java/C#
>>
>>60107599
There's nothing in C that encourages you to use static initialization.
>>
favorite book on ruby?
>>
>>60107593
>referentially transparent functions
A function is by definition referentially transparent.
>>
>>60107615
Not the way most programming languages let you define functions...
>>
>>60107613
i hear the well grounded rubyist is good but i've yet to even start. i'm so fucking swamped. ready for classes to be over.

i say this while playing shadowverse instead of studying lul
>>
>>60107618
I don't know of a single language which doesn't let you define functions (assuming it lets you define procedures).
>>
>>60107356
Learn x86, arm and risc-v.
>>
>>60107568
As long as all the static stuff cointains no state, it's probably fine. In that case, the static classes are just glorified namespaces.
If your codebase includes state everywhere you might want to look for a job in some place that doesn't encourage shooting yourself in the foot.
>>
>>60107671
That's exactly what they are. My guy.
It's almost like functional programming in C#
>>
>>60107528
>>60107544
>>60107551
What are some valid uses of "static"?
>>
>>60107719
static final
static native
>>
>>60107719
i'm partial to
static const char *const volatile register arr[]
>>
This week I've been busy with installing Arch Linux on a Samsung CB+

At work, I'm building a java library csv -> db. db -> csv exists, but apparently I've got to build the other way round myself. Tried dbunit, but that sucked.
>>
>>60107719
Anything that is "static const" is fine.
>>
File: 1487674720725.jpg (80KB, 500x500px) Image search: [Google]
1487674720725.jpg
80KB, 500x500px
>2016
>still using Turing complete languages
>>
File: smug39.jpg (35KB, 314x327px) Image search: [Google]
smug39.jpg
35KB, 314x327px
>>60107772
>2017
>not using quantum Turing complete languages
>>
>>60107767
sounds like a waste of time
>>
>>60107744
Get good.
static volatile const signed long long *register restrict volatile const arr[static register restrict volatile const];
>>
>>60107518
you can't instantiate a static class, for classes you dont want to have multiple instances of that would be a singleton which is a real concern (a class to handle a connection to a DB or a settings object or something that handles read/write for example would something you dont want 500 of)

using static class methods a lot turns into a sort of a poor mans way of using namespaces but in general i guess yeah don't use a lot of static class methods / variables frequently and question why it would even need to be static as it just exposes the potential for the state of that class to be changed somewhere else

you got discord or something anon
>>
>>60107554

Oh?

What thread should it be in?
>>
>>60107518
>Is this true?
No. You're teacher is retarded.
>>
>>60107772
>2017
>Still writing useless programs
>>
File: 1493353932143.jpg (136KB, 539x960px) Image search: [Google]
1493353932143.jpg
136KB, 539x960px
ja rule scammed a bunch of spoiled rich kids with a bogus music festival in the bahamas lmfao
>>
why do people dislike java so much? I prefer it to C++ for sure
>>
working on seeing if I can hook credit card magnetic head reader to arduino, and read cards, without the cc IC hooked up to the arduino.
>>
>>60107972
Why don't you compare it to a language that isn't also garbage?
>>
>>60107972
it's fine it's just shilling by C# tards and memeing by brainlets who were traumatized in school when they had to "learn" it in programming101
>>
>>60108005
>memeing
>>>/v/
>>
>>60107972
There just shills. They get paid by C++ to come shill their language every thread
>>
>>60108005
whats wrong with C#
>>
i want to connect to my vpn client on my raspberry pi with python, is there a way to do this?
>>
>>60108167
Yes. Don't use python
>>
>>60108167
Yes, even with python.
>>
>>60108142
http://www.groklaw.net/pdf/Comes-3096.pdf
>>
a = a++ + ++a;

???
>>
File: ISHYGDDT.png (9KB, 863x80px) Image search: [Google]
ISHYGDDT.png
9KB, 863x80px
>>60108252
>>
>>60107518
Yes, it's true that static classes are as bad as globals. But it's false that globals are inherently evil.
>>
File: 0x200.jpg (11KB, 200x200px) Image search: [Google]
0x200.jpg
11KB, 200x200px
My college CS undergrad program started us with C/C++ in my CS 101 class and every single class I've had to take has used C++ for examples since then. I'm two years deep and haven't seen a single line of Java except for comparison.

Is this a good thing? I know everyone hates Java on this board but I legitimately don't know anything about Java.
>>
>>60108276
it's easy as shit, shouldn't take long to learn Java if you're good at C++
>>
File: 1452228810512.png (53KB, 300x300px) Image search: [Google]
1452228810512.png
53KB, 300x300px
>>60108252
what is this suppose to do? both add 1 to a right? im lost
>>
>>60108276
it's fine. C++ and java are the best programming languages.
>>
File: akira_leave.png (224KB, 437x633px) Image search: [Google]
akira_leave.png
224KB, 437x633px
>>60108252
>>
>>60108276
i prefer java to c++ despite all the shilling c++ gets. If your good at one, then the other is easy. You should definitely learn java as well.
>>
++i++;

Where is your god now?
>>
File: 1468726331302.jpg (93KB, 694x642px) Image search: [Google]
1468726331302.jpg
93KB, 694x642px
>>60108279
>>60108287
>>60108303
Thanks bros, I guess I'll look at Java in my own time, but right now one of my classes is making me learn Assembly, and then next semester I have to build my own compiler from scratch for my term project, so it's gonna have to wait till after that.
>>
Just got a book about Clojure

What ppl used it for?
>>
>>60108316
>Prefix increment on something that isn't an lvalue
Dumbass.
>>
no, java is trash, redditor. leave. just fucking leave and spare yourself from further embarrassment.
>>
>>60108345
>>Postfix increment on something that isn't an lvalue
>Dumbass.
>>
>>60108252
++a, then a + a, then a++.

That gives you (a+1) + (a+1) + 1, or 2a + 3.
>>
>>60108376
>Postfix
I said prefix, though. Postfix binds more tightly than prefix, so it applies first and is valid.
>>
Uh-oh https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66139
RAII exception safety breaking bug slipping through cracks for two years, looks bretty bad actually
>>
>>60108378
it's just 2a + 2 because a++ returns a and you're assigning the result to a so the postfix increment has no effect. depends on the language though of course.
>>
>>60108411
Who the hell cares? Sepples is a horrible meme.
>>
>>60108426
>"""meme"""
>>>/v/
>>
File: IMG_20170428_003146.jpg (3MB, 1836x3264px) Image search: [Google]
IMG_20170428_003146.jpg
3MB, 1836x3264px
What do
>>
>>60108445
Learn how to take a screenshot
>>
File: 1484634038012.jpg (5KB, 370x334px) Image search: [Google]
1484634038012.jpg
5KB, 370x334px
Best syntax for logical operators?
>>
creating a program that forks a user defined amount of processes, which create a user defined amount of threads that calculate the summation of primes in a user defined range. It utilizes mutex locks, semaphores, and shared memory.

It's currently giving me a buffer overflow. Shit is at -1196335104.
>>
File: capture.png (66KB, 819x566px) Image search: [Google]
capture.png
66KB, 819x566px
Just finished conway's game of life in LC3 for a school project. Was a pain but also pretty fun.
>>
File: Propeller_Chip.jpg (138KB, 1024x576px) Image search: [Google]
Propeller_Chip.jpg
138KB, 1024x576px
Just bought myself one of these bad boys.

Basically like the chip on the Arduino, but 8 cores, some cool stuff built in (like video processing), and the chip itself is open source.

So now I'm researching its assembly language.
>>
>>60108474
F
A M A D A
N
G
>>
            Vec2 tangent = p2.sub(p1).normalize().add( p1.sub(p0).normalize()).normalize();

Thank you, Java, for teaching me that it is wrong to overload arithmetic operators because that might lead to code that is unclear.
>>
>>60108641
overloaded just turns it into
 ((p2 - p1).normalize() + (p1 - p0).normalize()).normalize()


how about instead of single lining it all, turn it into three expressions
>>
>>60108675
If I could overload I would turn it into how it looks in glsl, which is plenty clean for one line:
vec2 tangent = normalize( normalize(p2-p1) + normalize(p1-p0));

Since I can't I won't bother as it wouldn't help.
>>
File: dlang_chan.jpg (139KB, 470x545px) Image search: [Google]
dlang_chan.jpg
139KB, 470x545px
Threadly reminder that dlang-chan is not dead, and she's super duper cute! Say something nice about her, /dpt/!
>>
File: 1491469223028.jpg (34KB, 462x460px) Image search: [Google]
1491469223028.jpg
34KB, 462x460px
I am fucking idiot, working with Python.

I have the simple task of opening a .TXT with this information in it.
Kane Smith 67 56 62 70
Dane Blossom 61 71 72 81
Lark Slender 81 51 61 52

Totaling the averages of each individual and placing that sum next to their name.

How the fuck do I do that?
>>
>>60108713
for line in splitlines and for word in line.split()[1:]
>>
>>60108713
>I am fucking idiot
No need to explicitly say this, it's obvious by the "working with Python" part.
>>
File: file.png (82KB, 1545x547px) Image search: [Google]
file.png
82KB, 1545x547px
>>60107221
Currently getting drained trying to learn how to properly format a POST message to get info from some Android game server.

All I want to do is get some nice JSON, but these bastards are actually going to make me learn something new.

I'm trying to figure out the magic to sending a proper POST message in order to get proper tokens and MAC Id's in order to make GET requests to get info later on.

If anyone wants to share their knowledge feel free, I'm a bit frustrated that this isn't as easy as webscraping.

>pic related, its a packet trace
>>
>>60108641
Your welcome. C++ might allow atrocities like operator overloading, but not in my Java.
>>
>>60108445
Phoneposters are this fucking dumb. Jesus christ.
>>
>>60108713
Open file
Read by line
Split by space
Take elements 2 3 4 5 and add them
Concatenate element 0 and 1 with this total
Store it in however the fuck you want

There I did your home for you.
>>
File: 1491433109687.png (1MB, 1280x720px) Image search: [Google]
1491433109687.png
1MB, 1280x720px
>>60108728
>I am fucking idiot

I don't get any of this. I mean I understand I have to split the information and what not, I just don't know the code. Thanks anyway mate
>>
>>60108747
Hey, I agree that overloading anything other than arithmetic operators is fucking atrocious, especially when you're overloading actual language functionality.

But when doing
class1 + class2

is just "incorrect" despite being visually and mathematically unambiguous, you've gone too far int the other direction.
>>
>>60108786
>Using python already
>I just don't know the code
What do you mean by this?
Can you please study your textbook before coming here?
>>
>>60108786
google the following:
with open
split
splitlines
>>
>>60108786
Kind of a dumb question desu, you could have google that and got the appropriate answer m8.
>>
File: ffff.png (20KB, 363x503px) Image search: [Google]
ffff.png
20KB, 363x503px
Storing twitter users, have 3,7m so far. Have a couple of fun ideas for it.
>>
>>60108817
thank you
>>
>>60108819
nigga
>>
>>60108822
The fuck is the point of that?
>>
>>60108822
Tell us your ideas.
>>
>>60108819
Could have sworn I said nigga and not desu.
>>
>>60108713
average = lambda lst: sum(lst) / len(lst)
for line in lines:
print("%s: %s" % (' '.join(line.split(' ')[0:2]), average([int(x) for x in line.split(' ')[2::]])))
>>
>>60108817
You don't need splitlines for something like this. Just use a for loop and go
for line in file:
>>
>>60108876
Shouldn't show this young guy lambda, he should make a function or routine of computing the average.

Plus he lowkey doesn't know what that shit is, I know what it is and I'm disgusted. Python is so fucking ugly holy shit, its only second to objectiv c in shit tierness.
>>
>>60108876
>int
he never said he wanted to round up
Plus using lambda?
His teacher is going to know he didn't do that.
>>
>>60108914
>Shouldn't show this young guy functions
>he should make a function
What did he mean by this?
>>
>>60108891
but a file would be a file object,
if you mean for line in file.read() then it would be a string and each "line" would simply be a character.
>>
>>60108942
Since he's new he should make it himself, as in have a routine or function for calculating the average.

def fuckPython(a,b,c)
{
sum = a+b+c;
average = sum/3;

return the plaque or suffer the consequences


}

>inb4 you don't need a semicolon
>>
>>60108957
with open(filename) as file:
for line in file:
>>
>>60108977
lambda is just a throwaway anonymous function. But I agree, he should write functions because there is no way his teacher is going to believe he knew how to use lambda.
>>
>>60108977
What are you even on about? You said he shouldn't be using functions, then you contradicted yourself by saying he should use them.
>>
>>60108979
That's pretty cool, thanks
>>
>>60108986
>he should write functions because there is no way his teacher is going to believe he knew how to use a function.
What were you going to mean by this?
>>
>>60108977
>>60108994

Why are you fucks still arguing over the best way to calculate an average?
>>
>>60109004
Just cause you know how to write functions doesn't mean you know how to write them with lambda.
>>
>>60107273
943381915

As3 is best language
function isPSquare(n:int):Boolean
{
if(n == 0) return false;
var i:int = 1;
while(true) {
if(n < 0) return false;
if(n == 0) return true;
n-=i; i+=2;
} return false;
}

const UBOUND:uint = 2000000; // Upper bound -> 2 000 000
var psquares:Vector.<uint> = new Vector.<uint>;
var pSum:uint = 0;
for(var i:int = 1; i <= UBOUND; i++) {
if(isPSquare(i)) psquares.push(i);
}
for each (var j:int in psquares) pSum += j;
trace(pSum);
>>
>>60109012
Even if you can somehow know one without knowing the other, learning about it should take anyone about 3-5 minutes depending on their retardation.
>>
>>60109032
Lmao you really think someone who ask others to do his homework on /dpt/ is going to have the impression of someone who self studies on the internet? More likely his teacher is going to believe he ask someone to do his homework.
>>
>>60108876
i fixed it

print('\n'.join(map(lambda line: "%s: %s" % (' '.join(line.split(' ')[0:2]), sum([int(x) for x in line.split(' ')[2::]])/len(line.split(' ')[2::])), lines)))
>>
>>60109055
This triggers me
>>
>>60109055
The fuck is this?
The fuck is that?
>>
>>60108641
>>60108690
kill yourself retard

vec2 tangent = normalize(add(normalize(sub(p2, p1)), normalize(sub(p1, p0))));


even in C++ operator overloading is completely unnecessary and should generally be avoided.

you should put it on multiple lines anyway with more descriptive variable names

fucking smug retard
>>
File: dslut.png (539KB, 617x615px) Image search: [Google]
dslut.png
539KB, 617x615px
>>60109023
Vector.<type>

God damn that's fucking ugly.
>>
>>60109104
Yes. Yes it is.
Flash also has an automatic timeout after 15sec of execution, and as such, i cant compute higher numbers without it shitting itself and dying
>>
>>60109140
>Flash also has an automatic timeout after 15sec of execution
But why? Safety, performance, retardation?
>>
>>60109176
>Flash
>Safety
Hahahahahahhahahahaha... no
>retardation
And incompetence.
for more proof:
var i:uint = 0;
if(i is Object && i is Number && i is int && i is uint) trace(i) // Prints 0
>>
Do you use rust nightly? If yes, why?
>>
>>60109207
no because i'm not a flaming sjw mozilla employee faggot
>>
>>60109214
He said "if yes, why?", not "if no, why not?".
>>
>>60109214
What?
>>
>>60109195
So a uint isn't a primitive datatype, and uint is derived from int which is derived from Number which is derived from Object. Is this some javascript nightmare?
>>
>>60109227
shove your coc up your ass

https://www.rust-lang.org/en-US/conduct.html
>>
>rustfags
https://www.youtube.com/watch?v=Wllc5gSc-N8
>>
>>60109243
What does that have anything to do with my question?
>>
>>60109251
Who are you quoting?
>>
>>60109234
ECMAScript is a horrible standard, apparently
>>
critique it
// LRU Cache
class LRUCache {
public:
LRUCache(int capacity) : c(capacity) {}

void touch(int key) {
pair<int, int> x = *s[key];
a.erase(s[key]);
a.push_front(x);
s[x.first] = a.begin();
}

int get(int key) {
if (! s.count(key))
return -1;
touch(key);
return a.begin()->second;
}

void set(int key, int value) {
if (s.count(key)) {
touch(key);
a.begin()->second = value;
} else {
if (s.size() >= c) {
s.erase(a.rbegin()->first);
a.pop_back();
}
a.push_front(make_pair(key, value));
s[key] = a.begin();
}
}
private:
map<int, list<pair<int, int> >::iterator> s;
list<pair<int, int> > a;
int c;
};
>>
>>60109295
>class
Stopped reading right there. 0/10
>>
File: 1405798839790.jpg (50KB, 849x852px) Image search: [Google]
1405798839790.jpg
50KB, 849x852px
>>60109295
https://www.youtube.com/watch?v=n3Kc6wB7URo
>>
>>60109307
I think we should all fap to her at least once.
>>
>>60109251
What the fuck is this?
When the fuck did this happen?
What the fuck....
>>
>>60109277
Man, I hope you're at least having fun; because having to use this crap in a compsci course in the year of our lord 2017 is bullshit.
>>
How about this? https://leetcode.com/problems/wildcard-matching/
class WildCard {
public:
bool isMatch(const char *s, const char *p) {
const char *star = NULL, *ss = s;
while (*s) {
if (*p == '?' || *p == *s)
p++, s++;
else if (*p == '*')
star = p++, ss = s;
else if (star)
p = star+1, s = ++ss;
else
return false;
}
while (*p == '*') p++;
return !*p;
}
};
>>
>>60109345
>class
Absolute trash. Get the fuck out of here.
>>
File: why.jpg (11KB, 245x245px) Image search: [Google]
why.jpg
11KB, 245x245px
a shitty fucking rails e-commerce app that i forked off of solidus.

it was kind of a freelance-but-really-helping-a-friends-friend sort of deal that started a year ago and then he comes back from the dead. the current state of shittiness is my fault mostly for not gathering requirements very well.

its my first time doing e-commerce and some research suggested that a framework was better than rolling your own buuut if i had just gathered my requirements better i'd probably be finished by now instead of trying to hunt down how to add a fucking field to a model/registration view.

i feel like i should like rails and ruby, but i am having such a hard time doing so
>>
>>60109332
Well, you can write as obscure fucking code as you want, and it'll probably run
So thats neat.
>>
anyone else getting into idris now that it's 1.0?

just got edwin's book in the mail and i'm really excited to dig in!
>>
>>60109463
lol nerd
>>
>>60109523
fair. i'm real gay for type systems
>>
File: 1462625286160.jpg (86KB, 650x650px) Image search: [Google]
1462625286160.jpg
86KB, 650x650px
>>60109463
Does the book cover proofs?
>>
File: 4db.png (62KB, 860x650px) Image search: [Google]
4db.png
62KB, 860x650px
>>60109584
>>
>>60109584
it doesn't explicitly have a chapter on the topic, but i've not been able to actually dig in yet so perhaps there's something?
>>
File: 1482751787140.jpg (33KB, 392x417px) Image search: [Google]
1482751787140.jpg
33KB, 392x417px
i made a twitter bot that tweets random images from random boards paired with random text posts every half hour. honestly the hardest part was trying to get python to work properly with cron

anyone wanna see it?
>>
>>60109721
>Python
>>
File: 1457280710822.png (722KB, 834x1367px) Image search: [Google]
1457280710822.png
722KB, 834x1367px
I have never seen a black person use Idris or Haskell. Really makes you think, doesn't it?
>>
>>60109721
i wanna see it, you should make it /g/ specific though. Daily /g/ bot
>>
>>60109788
why dont you learn a real programming language and then comeback
>>
File: 1462713695054.jpg (57KB, 637x685px) Image search: [Google]
1462713695054.jpg
57KB, 637x685px
>>60109808
How can a programming language be "fake"?
>>
>>60109788
I've never seen anyone use Idris or Haskell. Really makes you think, doesn't it?
>>
>>60109798
i feel like that would be a lot more boring to be honest.

the twitter is @bot4chan. i literally *just* started it up so theres only one post right now and its pretty garbage.

it's inspired by a chatbot I wrote for a discord server my friends and I hang around in. you'd just type !chan board1 board2 and it would pair a random image from board1 with a random textpost (stripped of replies) from board2. it turned out to have some really funny combinations so I decided to automate it

speaking of discord, anyone know any good alternatives that have message history? its the one thing preventing them from moving to IRC.
>>
File: 14605787135170.jpg (36KB, 213x214px) Image search: [Google]
14605787135170.jpg
36KB, 213x214px
>>60109820
I didn't mean to hurt you.
>>
>>60109880
Could you stop reminding the world that 4chan exists? The influx of newfags is already too much, we don't need more shitposters.
>>
>>60109463
I've started it a week ago, I hope it'll help me to get into dependent types, something I wanted to do for ages.
>>
>>60109893
you should keep trying to learn English
>>
>>60109896
>le sekrit club
>>>/r/eddit
>>
File: 1458252077357.jpg (72KB, 459x483px) Image search: [Google]
1458252077357.jpg
72KB, 459x483px
>>60109908
Sometimes the truth is hard to understand.
>>
File: 1482504997425.png (291KB, 750x366px) Image search: [Google]
1482504997425.png
291KB, 750x366px
>>60109904
>>60109915
>>
>Announcing Rust 1.17
https://blog.rust-lang.org/2017/04/27/Rust-1.17.html
How come no one's posted it yet? I can finally write `Struct { a_field, another_field }` instead of `Struct { a_field: a_field, another_field: another_field }`.
>>
>>60109953
Sorry, I don't use languages which treat terms and types as different things.
>>
>>60109938
Only when being expressed by someone with a loose grasp on the language.
>>
>>60109953
Holy shit, 2018 year of Rust confirmed!

Kys
>>
>>60109207
Only when i want to play around with a unstable feature
>>
>>60109953
>https://blog.rust-lang.org/2017/04/27/Rust-1.17.html
static NAME: &'static str = "Ferris";

ewww
>>
>>60108252
UB
>>
If Rust is so safe then why does Nasa still use C? I thought Nasa was anal about safety?
>>
File: 1485010338480.png (98KB, 400x410px) Image search: [Google]
1485010338480.png
98KB, 400x410px
>>60109971
If you have anything to say, it's better to say it, than to live with regrets for the rest of your life, you know?
>>
>>60109207
Only when I run clippy, otherwise stable is good enough.
>>
>>60108697
She's not even cute.
>>
>>60110009
Literally in the next paragraph:
>Rust 1.17 will allow you to elide the 'static, since that’s the only lifetime that makes sense:
static NAME: &str = "Ferris";
>>
>>60110058
>
static NAME: &'static str = "Ferris";

eww
>>
>>60110024
Rust is still meme-tier at this point.
Anybody who is doing anything serious isn't going to change to unproven shit for absolutely no reason.
>>
Hey guys, so I just made my first android app which is about pointing with the camera to a number at a certain hour and then returning specific info depending on the hour and number.

Only problem is that when I go change the hour in the system and return to the app the variable of the hour in the app doesn't update.

So I have 2 options, either make it so every time I exit and re-enter the app, It reloads or make it so the hour variable revalues itself every 10 seconds or so.

Problem is, I don't know how to do either of those things, any ideas? I've googled it but can't seem to find the answer, most timers for the functions don't seem to work for me and I would rather reload the app when I exit and re-enter it.
>>
>>60110128
>"""meme"""
>-tier
>>>/v/
>>
Rustshills please stop.
No one wants your SJW language here
>>
>>60110263
I do.
>>
>>60110263
Anon, what.
>>
What does /g/ think of Blow?

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

Apparently all languages are slow, so he decided to make his own language which is faster than c++/rust
>>
>>60110426
It's a waste of time, yet another "I'm gonna make my own language which is basically the same as the old languages but with a small twist", see D, Nim and Crystal.
>faster than c++/rust
How tho? C/C++ is the fastest you can get because of UB and state-of-the-art codegen, and Rust is fast because of borrow checker. What can you do differently to be even faster?
>>
$ file rustbinary 
rustbinary: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=a56534b6fa8d4220953be66a999c15f691bc6cd9, not stripped
$ file /bin/cat
/bin/cat: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=66df2f30dbd2b67942c977aa28882c84071f9a74, stripped


Why does the Rust compiler emit an executable ELF "shared object" rather than just a straight ELF executable?
>>
>>60110476
He explains here
https://youtu.be/gWv_vUgbmug?t=25m46s

Something about doing 'everything' at compile time.
>>
no bully
github /Undercore/ProxyScraper.py/blob/master/SourceCode.py
>>
>>60110491
I have no time to watch it tho.
> doing 'everything' at compile time.
Wew, what a novel thought, it's almost as if templates and constexpr aren't real and compiled haven't been doing CTFE for 20 years no.
>>
i need help writing a method that returns available reservations
each reservation lasts 2 hours and can be made every half hour

10:00
10:30
11:00
11:30
12:00
etc.

if the restaurant have 200 seats, and i want to check how many seats i available at 11:30
>>
>>60110487
The only difference is what you can dynamically link against a `shared object` elf file, both files can be executed directly. On my linux box /usr/bin/mysql and /usr/bin/ssh are `LSB shared objects` rather than `LSB executable`.
>>
>>60110531
> i need help
You need to drop out of school and find a job at McDonald's since you can't write a trivial piece of code by yourself.
>>
>>60110557
So basically I can link rust programs into other programs? but then that would have conflicting _start symbols.
Also it's annoying because shared objects have a different icon than executables in pcmanfm.
>>
>>60110531
>method
Wrong thread.
>>
>>60110585
> So basically I can link rust programs into other programs?
Yes, dynamically.
> but then that would have conflicting _start symbols.
No, because you wouldn't be linking against it statically. Basically, you dlopen the executable and call its public symbols. You can't do that with LSB executable AFAIK.
>>
haskell

anyone know how to redefine head so that head[] returns empty set?
>>
>>60110714
> empty set
what
>>
>>60110714
It can't be done, 'head' takes a list and returns one element of that list, returning a list, albeit an empty one, would break the type signature.

head :: [a] -> a
>>
>>60110714
>>60110747
head' :: [a] -> Maybe a
>>
>>60110714
https://hackage.haskell.org/package/safe
>>
File: 1491582190718.png (606KB, 1080x1080px) Image search: [Google]
1491582190718.png
606KB, 1080x1080px
>>60107221
>waste hours checking why VS wont output .exe file

>turns out source file properties were set to "not taking part of the program"

>google abit more on MASM
>realise it's not fucking portable, and that NASM is actually what i should be learning for asm portability
>>
>>60110762
Kill yourself, you retarded frogposter.
>>
I'm thinking of learning Rust. Also there's a hackerrank competition today.
>>
>>60110821
k
>>
File: 1491163669199.gif (669KB, 480x480px) Image search: [Google]
1491163669199.gif
669KB, 480x480px
>>60110804
>>
>>60110762
Who are you replying to?
>>
I'm trying to compare memory used when filling very big arrays in Java and in C++. Is there a way to monitor the amount of memory (RAM or even better if its heap and stack separately) used in programs written in these two languages?
>>
>>60110714
You should use Idris, calling head on an empty list is a type error in it.
>>
>>60110888
RES column in htop?
>>
>>60110906
Thanks, I'll have to look into that one.
But is there a way to do it from inside of the code? Like setting a memory value before the array fill a after, and then subtracting or something like that?
>>
File: pepesad.jpg (29KB, 640x480px) Image search: [Google]
pepesad.jpg
29KB, 640x480px
>>60107221
2nd problem of Project Euler
>>
>>60110982
I don't know about Java, but for C++ you can use your allocator's statistic, like https://www.gnu.org/software/libc/manual/html_node/Statistics-of-Malloc.html#Statistics-of-Malloc for GNU libc allocator. Then again, the results wouldn't be comparable since the memory management mechanisms are too different, I think you'd be better off with some external tool like valgrind: http://valgrind.org/docs/manual/ms-manual.html .
>>
>>60107309
>tensorflow
>web design
How retarded are you?
>>
>>60108411
>anonymous struct with non-trivial destructor
really, does anyone ever use that?
>>
>>60111052
>>60111276
Who said this?
>>
>>60111280
He said that tensorflow isn't programming and that it is web design.
>>
Is there any easy tool to create PDF pages in java?
Specially text that won't be just in a single page of A4?
I can't seem to get hang of itext and there is no structural info about it.
>>
>>60111290
Where did he say "web design"?
>>
Where to learn c++11?
>>
File: 4thEnglish.jpg (47KB, 591x722px) Image search: [Google]
4thEnglish.jpg
47KB, 591x722px
>>60111429
>>
I need a clever and witty name for my programming language, suggestions?
>>
>>60111686
Wittiver
>>
File: 1432228367416.gif (3MB, 580x328px) Image search: [Google]
1432228367416.gif
3MB, 580x328px
I need an anime name for my programming language, suggestions?
>>
>>60111886
G
>>
>>60111886
LoliC
>>
>>60111886
bushido code
>>
>>60111886
Thic+c
>>
>>60111686
What does your language have?
What inspirations did you take?
>>
>>60107392
>The C programming Language
>The C++ programming Language
> The GNU C Library Reference Manual

or you can take the easy way and just practice.
>>
File: Genius.jpg (13KB, 220x285px) Image search: [Google]
Genius.jpg
13KB, 220x285px
/* Copyright 2017 anon

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

#include <iostream>
#include <string>

using namespace std;

int main()
{
string s1 = "the end";
for(int i=0; i<=100; i++)
{
if (i%3==0 && 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 <<endl;
}
}
cout << s1 <<endl;
return 0;
}
>>
>>60112399
This is a non-compliant "Fizz buzz". The spec clearly says to print "Fizz", "Buzz" and "Fizz Buzz". Also it doesn't say anything about printing "the end".
>>
>>60112399
> using namespace std;
Bad practice outside a funtion body.
> #include <string>
You don't need std::string here.
> (i%3==0 && i%5==0)
i%15==0
Overall 5/10, woudn't hire.
>>
>>60112399
Worst fizzbuzz i have seen today. 3/10
>>
>>60111390
He linked to the web dev general:

>>60107309
>Not programming.
>>>/g/wdg/
>>
>>60112512
So? Where did he specifically say the words you quoted?
>>
>>60112399
defmodule FizzBuzz do
def run(n) do
1..n
|> Enum.map(fn(n) ->
case {rem(n, 3), rem(n, 5)} do
{0, 0} -> "FizzBuzz"
{0, _} -> "Fizz"
{_, 0} -> "Buzz"
{_, _} -> n
end
end)
|> Enum.each(&IO.puts/1)
end
end
>>
>>60112530
What language?
>>
>>60112543
Elixir
>>
>>60112512
You're responding to one of the resident /dpt/ non-tripfag recognizable posters, the crossboarder /jp/-wannabe who doesn't even program. You're best off just ignoring his posts or filtering phrases like "who are you quoting?"
>>
#include <iostream>

int main()
{
using namespace std;
for(int i=0; i<=100; i++)
{
if (i%15==0)
{
cout << "fizz buzz\n";
}
else if (i%3==0)
{
cout << "fizz\n";
}
else if (i%5==0)
{
cout << "buzz\n";
}
else
{
cout << i <<endl;
}
}
return 0;
}


execution time : 0.024 s
>>
File: 1485474645965.png (226KB, 700x500px) Image search: [Google]
1485474645965.png
226KB, 700x500px
>>60112553
I think I'm going to borrow its tuple syntax.
>>
>>60112569
Garbage. It's not even fizzbuzz.
>>
Memelang version, extra spicy:
use std::fmt;

#[derive(Clone, Copy)]
struct Fizzbuzz(u32);

impl fmt::Display for Fizzbuzz {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match (self.0 % 3, self.0 % 5) {
(0, 0) => write!(f, "Fizzbuzz"),
(0, _) => write!(f, "Fizz"),
(_, 0) => write!(f, "Buzz"),
_ => write!(f, "{}", self.0),
}
}
}

impl Iterator for Fizzbuzz {
type Item = Fizzbuzz;

fn next(&mut self) -> Option<Fizzbuzz> {
self.0 += 1;
Some(*self)
}
}

fn main() {
for fb in Fizzbuzz(0).take(100) {
println!("{}", fb);
}
}
>>
>>60107221
Is Scala worth using /dpt/?
>>
File: 1490540156550.jpg (66KB, 546x618px) Image search: [Google]
1490540156550.jpg
66KB, 546x618px
Can someone write a Haskell fizzbuzz without using the IO monad sequencing?
>>
What is the essence of design patterns in OOP languages?
>>
>>60112774
>print without using IO
>>
>>60112620
idiomatic/10
I've discovered recently it's actually quite handy to encapsulate non-trivial iteration logic (like iterating over a rectangle inside 2-dimensional space) into Iterator instances.
>>
>>60112846
Did you even read my post?
>>
>>60112774
> fizzbuzz = undefined
> map fizzbuzz [1..100]

ghci will then display it, and you didn't have to use IO
>>
File: 1470306362471.png (15KB, 300x300px) Image search: [Google]
1470306362471.png
15KB, 300x300px
>>60112863
I'm not kidding though...
>>
File: g-dexists.gif (2MB, 235x240px) Image search: [Google]
g-dexists.gif
2MB, 235x240px
>mfw kotlin exists
>>
>>60112899
PRINTING REQUIRES INPUT AND OUTPUT BECAUSE ITS A SIDE EFFECT
SAYING ONE CAN'T USE THE IO FACILITY IN HASKELL IS RETARDED
>>
>>60112926
Where did I say "Don't use I/O"? I simply said that you can't use do-notation or >>= or >>.
I wasn't even going to explain it to you because you're so rude.
>>
>>60107518
>static classes / methods / variables

Static classes can be bad, but static methods are quite useful, and often used.
>>
>>60112966
mapM (putStrLn . fizzbuzz) [1..100]
>>
>>60113010
mapM is a form of sequencing and it uses bind. I mean just with putStrLn and recursion.
>>
>>60113052
Fuck off faggot, using IO is perfectly ok.
>>
>>60113052
You can't, you need >> or >>= to do anything with IO.
>>
>>60113066
that's not what anonymous asked for though
>>
>>60113066
Maybe you should take a break? You seem upset.
>>60113099
That's what I've been thinking as well but I'm still not convinced.
>>
>>60113145
you could putStr a big string that contains the whole fizzbuzz output from 1 to 100 separated by newlines, in this case there's no sequencing.
>>
>>60113145
>>= is literally the essence of monads, you can't do anything useful without it
>>
>>60113177
Yes you can do one and only one operation, see >>60113171. But it's kinda pointless.
>>
Sorry, noob question... How would I take multiple inputs but break the process if one of the inputs is wrong?

e.g. "Enter first name" -> "Enter last name" -> "Enter age"
but if you enter an invalid first name then it produces an error message immediately instead of waiting until all inputs have been entered.

Using a bunch of nested if/elses seems really messy.
>>
>>60113177
Who are you quoting, anon?

t. quotebot
>>
>>60113192
putStr is an IO-specific function. You can't do anything useful in monads in general without bind (or join or whatever equivalent).
>>
>>60113145
What you're asking is like saying "How do I loop without for, while, do while, and recursion syntaxes"
>>
>>60113197
terminate the program or return from the function.

This thread is reserved for people who've finished reading the tutorial btw. But I excuse you for this time.
>>
>>60113197
Use monads, they're pretty handy.
A transformer around the Maybe and IO monad.
>>
>>60113171
Yeah, that's it.
>>60113229
Not really. But the answer would be pretty simple if we assume that looping is the only operation in the language.
>>
>>60113259
That's a hack though, why limit yourself and not use the standard facilities?
>>
Damn, 20+ replies for fizzbuzz in Haskell.

People aren't kidding when they say it's a puzzle-oriented language.
>>
New thread:
>>60113416
>>60113416
>>60113416
>>
>>60113325
I'm using a subset of Haskell which doesn't have monads yet.
>>
>>60113480
Use strictness annotations and unsafePerformIO. Or, alternatively, quit this madness.
>>
>>60113497
I don't have any of that in my language though.
>>
>>60113547
http://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Base.html#bindIO
could break open the IO type using its definition and do shit like link. Not saying it's generally applicable, tho, maybe your subset doesn't define IO like GHC does, in which case try using the same idea.
>>
>>60113603
Thanks, I was planning to do something similar after I add explicit Λ-functions.
Also, what do you mean by "strictness annotations"? The only thing that comes to mind is '!'.
>>
>>60113701
It's been a long time since I last haskleld, but what I'm thinking of is stuff like seq and $! (Hoogle them) that allows you to force the program to evaluate something before something else despite lazy evaluation. Given that most values are pure, this is not used often, but it makes sense if values aren't pure (think unsafePerformIO) or if it's an optimization.
>>
>>60113701
>>60113804
And please, please wrap all this impure shut into a monad ASAP!
>>
Hi, I'm learning python3, I want to do exercises in bulk,

for example:
def a(a,b):
return a*b
def b(a,c):
return a+b

fun = input()

#fun would now be "a"

fun(1,2) # which would execute a

this sounds incredibly silly, I know, but is there a way to do this?
>>
>>60109023
He said first 2 million perfect square numbers, not all perfect square numbers <= 2 million
Thread posts: 321
Thread images: 48


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