[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: 314
Thread images: 54

File: Algorithm_Design.jpg (42KB, 403x500px) Image search: [Google]
Algorithm_Design.jpg
42KB, 403x500px
Old thread: >>59377805

What are you working on /g/?
>>
>>59382347
>no anime picture
shit thread
>>
File: 1456891155662.png (251KB, 600x490px) Image search: [Google]
1456891155662.png
251KB, 600x490px
Do I pass the type checker?
>>
>>59382347
Ok, I guess I'm ready to dive into some esoteric shit. Prolog, here I come
>>
File: 1421139415594.jpg (112KB, 1358x765px) Image search: [Google]
1421139415594.jpg
112KB, 1358x765px
I̶/̶O̶
>>
>>59382347
Shitposting about my favorite language on /dpt/ of course.
>>
>>59382347
>>no anime picture
good thread!
>>
>>59382373
>>
>no anime
>good thread!
>>>/r/ibbit
>>
File: 895.jpg (41KB, 554x439px) Image search: [Google]
895.jpg
41KB, 554x439px
>>59382373
How did you end up on an Anime website?
>>
>>59382371
is it you, perlfag?
>>
File: 1488771257847.jpg (61KB, 642x792px) Image search: [Google]
1488771257847.jpg
61KB, 642x792px
>>59382361
>>
>>59382373
Hello. Here's a link to help you get home
>>>/r/ebbit
>>59382382
It seems to be lost.
>>
I'm very new at python 2.7

If I make a for loop that contains an if statement to check if an item in a list matches a certain case. Things work fine.
If I make certain matches delete the list element after doing something with it, using list.remove(), and there's still loops that should run after this happens, the loop stops/misses the next item on the list.

I think this is because if I'm deleting an element of a list, the following items are shifted one index position up the list, such that a different list element now occupies the index that was just checked by the loop, and the loop checks elements via index. Such that if the list only contained two elements, at index 0 and 1, and the element at 0 was just deleted, when the loop goes to 1 its empty.

So how should I iterate through a list and selectively check for and delete certain elements, but check for and do something else with other elements?

Here's an example of what I'm talking about:

my_list = ['x', 'y']
my_list_copy = ['x', 'y']

def foo():
for i in my_list:
if i == 'x':
print "X is in list."
my_list.remove('x')
elif i == 'y':
print "Y is in list."

def bar():
for i in my_list_copy:
if i == 'x':
print "X is in list."
elif i == 'y':
print "Y is in list."

foo()
bar()


foo() only prints "X is in list", even though x and y are in list.
bar() correctly prints both strings as it lacks the line with list.remove().
>>
>>59382383
(perl is an abomination.)
>>
>>59382361
>>59382382
>>59382381
>>59382393
Just stop bumping this shit and make another /dpt/ thread and report this one, you niggers.
>>
>>59382386
>gulags
No, his kind should be dealt with immediately.
>>
>>59382404
I'm actually a triple agent. Sorry.
MI6 sent me.
>>
File: trump.jpg (97KB, 634x821px) Image search: [Google]
trump.jpg
97KB, 634x821px
>>59382386
why do they always have weird hair on their heads?
>>
>>59382395
>python
Didn't read past this. Fuck off back to your subreddit.
>>
File: wbwAVIj[1].png (128KB, 1366x768px) Image search: [Google]
wbwAVIj[1].png
128KB, 1366x768px
What's wrong with it? I wanted to install NLTK. I use Python 3.5.2 on Win32
>>
>>59382395
if you're new then you should learn Python 3, IMHO
>>
>>59382430
They're too busy changing the world to care about their appearance, you insect.
>>
>>59382395
>>59382442
kek
try using a less shit language next time
>>
>>59382457
fewer*
>>
>>59382455
lol you think that hair and those mustaches are low maintenance, you easily conned retard?
>>
>>59382430
>they
Leftists?
>>
>>59382474
I actually know a thing or two about hair since I was the best hair braider in prison.
>>
File: qtpi.jpg (68KB, 606x768px) Image search: [Google]
qtpi.jpg
68KB, 606x768px
>>59382486
authoritarian dictators in general
>>
Does anyone know if I can use cv2.calcHist() to calculate multidimensional histograms? I can do it in vanilla Python plus numpy (because it makes arrays nicer) but shit's slow as fuck with all those loops etc.

import numpy as np

BINS = 5

img = np.array([ \
[[255, 0, 0], [255, 0, 0], [255, 0, 0], [255, 0, 0]], \
[[255, 0, 0], [128, 255, 0], [255, 255, 0], [ 0, 0, 0]], \
[[ 0, 0, 0], [255, 255, 0], [ 0, 255, 128], [ 0, 255, 255]], \
[[ 0, 0, 255], [ 0, 0, 255], [ 0, 255, 255], [ 0, 255, 255]] \
]).astype(np.uint8)

histo = np.zeros((BINS, BINS, BINS)).astype(np.uint8)

for row in img:
for pixel in row:
histo[pixel[0] * BINS / 256, \
pixel[1] * BINS / 256, \
pixel[2] * BINS / 256] += 1

print histo


>>59382395
>I think this is because if I'm deleting an element of a list, the following items are shifted one index position up the list
That's the problem, yes.
You should make a copy of the list prior to iterating:
new_list = my_list[:]
for i in my_list:
if i == "x":
new_list.remove("x")
>>
>have to implement GUI with sdl and opengl because there is no decent library that would work on mobile and desktop
Why must everything suck so bad?
>>
>>59382500
well, you seem to be posting images of exclusively leftists so i wondered.
>>
>>59382404
The other thread is going to be deleted.
>>
>>59382505

Wow that's simple, can't believe I didn't think to try.

Thanks a lot.
>>
>>59382505
>python
i heard they are very helpful at /r/python
>>
>>59382512
I know what you mean hehehe #nevertrump
>>
File: 1467934642418.jpg (87KB, 1600x1067px) Image search: [Google]
1467934642418.jpg
87KB, 1600x1067px
>>59382530
You're welcome.
>>
>>59382537
I honestly don't think you do.
>>
>>59382545
how old is this faggot? can't be long before he dies, right?
>>
File: cringe.jpg (13KB, 200x200px) Image search: [Google]
cringe.jpg
13KB, 200x200px
>>59382512
>Hitler
>left
>>
File: 1486261432976.jpg (41KB, 750x623px) Image search: [Google]
1486261432976.jpg
41KB, 750x623px
>>59382529
damn right!
>>
@59382589
>cringe.jpg
yeah, i'm not surprised your kind can't see reality as it is.
must be from plebbit infecting your mind.
>>
What was that game where you could have conveyor belts and a frying pan and a tennis racket and shit and make machines.
>>
Reimplementing unix pipes without I/O.
>>
>>59382621
The Incredible Machine
>>
>>59382570
>how old is this faggot?
he's a 63 years young anti-american communist
>>
File: pathetic.png (205KB, 500x307px) Image search: [Google]
pathetic.png
205KB, 500x307px
>>59382617
>I'm a political illiterate and have never read a history book in my life, I can only parrot slogans and labels
>>
>>59382649
also he's morbidly obese. it really can't be that long until it's finally over. i've been waiting for quite a while now.
>>
@59382654
Who are you quoting, plebbitor?
>>
>>59382655
don't hold your breath, he's worshiped all over the world like a god and that tends to prolong their lives by decades
>>
>>59382655
I keep thinking the same about GRRM for years now and yet he's still alive.
>>
>>59382696
he can live. i don't really have a deep hatred for him.
>>
File: 1488467091219.png (974KB, 900x900px) Image search: [Google]
1488467091219.png
974KB, 900x900px
>tfw you write 'foundational knowledge of' instead of 'basic knowledge of' in your resume
>>
>>59382725
>being a liar
>>
File: 3891203821.jpg (23KB, 680x680px) Image search: [Google]
3891203821.jpg
23KB, 680x680px
>>59382741
i'm not though
>>
File: 1474062352177.png (67KB, 400x400px) Image search: [Google]
1474062352177.png
67KB, 400x400px
>>59382725
That's pretty good.
>>
>>59382725
>>59382741
Who are you quoting??
>>
File: Selection_20170313_16:19:44.png (7KB, 380x110px) Image search: [Google]
Selection_20170313_16:19:44.png
7KB, 380x110px
>>59382779
>>
>>59382603
>implying Trump doesn't like anime
He even respects 2D girls rights.
>>
>>59382791
that wasn't the only mistake they're.
>>
>>59382395
Quit while you're ahead and use 3.x

Stop learning legacy shit. Its legacy for a reason.
>>
>>59382791
Someone get this hothead outta here!
>>
File: 1474325315193.jpg (44KB, 636x616px) Image search: [Google]
1474325315193.jpg
44KB, 636x616px
Employed Haskell programmer reporting in <3
>>
>>59382510
Qt
>>
>>59382922
Reported for telling lies on the internet.
>>
>>59382935
He doesn't tell he is employed AS a Haskell programmer, chill down.
>>
In java, how would i read two separate parts of a line in a file based on a space?
So if i have a string x and an int y, and i have the file with the line:
Hello 12
How would i give Hello to x and 12 to y?
Only done it through lines at the moment.
>>
>>59382975
Read the line from the file, store it in a string,
indexOf()
the space, and substring the two pieces around the space would be my guess.
>>
>>59382922
no way!!
>>59382962
oh..
>>
File: 1456252392769.gif (1MB, 450x540px) Image search: [Google]
1456252392769.gif
1MB, 450x540px
Is Haskell anime?
>>
>>59382367
>prolog
>esoteric
baka senpai
>>
>>59383143
No, but Lisp is.
>>
>>59383167
But anime isn't garbage.
>>
>>59383208
Yes it is.
>>
File: lisplogo_fancy_256.png (41KB, 256x223px) Image search: [Google]
lisplogo_fancy_256.png
41KB, 256x223px
>>59383167
Lisp is a tentacle hentai.
>>
>>59383224
No it isn't.
>>
>>59382975
Don't remember if java has a split function, but that's what you're looking for. If it doesn't exist in the standard library, I'm sure somewhere out there on Stack Overflow has it
>>
>>59383247
Wipe the tears off your face, boy.
>>
>>59383208
>>59383224
>>59383239
>>59383247
Lain.
>>
>>59383256
>boy
I have started my transition already, you asshole.
>>
>>59382923
>doesn't export C-api
It's shit.
>>
>>59383324
There is no alternative.
>>
>>59383239
The lisp alien is the worst logo ever and I don't understand why lisp-weanies use it.
>>
>>59383332
>sdl with opengl to implement GUI
Actually these is nuklear so I don't have to do it myself. Life is still miserable.
>>
I am making a new anime thread.
Who's with me?
>>
>>59383346
There aren't better drawings of the Lisp alien, that's why.
Also you're pretty much looking at programmer art
>>
>>59383346
Don't hate on the suave space toad.
>>
>>59383370
Me and my hired guns are with you.
>>
File: cl.jpg (48KB, 430x305px) Image search: [Google]
cl.jpg
48KB, 430x305px
>>59383406
>>59383389
Way better
>>
I decided to make a web business application it made a lot of money but holy shit it is so boring programming web business apps! Why didn't you guys warn me how boring it is
>>
>>59383439
>web
fuck off scrub.
>>
File: 1482831679157.jpg (55KB, 600x900px) Image search: [Google]
1482831679157.jpg
55KB, 600x900px
>>59383239
>>59383430
Garbage.
>>
>>59382347
Shellsort is a generalization of insertion sort that allows the exchange of items that are far apart. The idea is to arrange the list of elements so that, starting anywhere, considering every hth element gives a sorted list. Such a list is said to be h-sorted. Equivalently, it can be thought of as h interleaved lists, each individually sorted.[6] Beginning with large values of h, this rearrangement allows elements to move long distances in the original list, reducing large amounts of disorder quickly, and leaving less work for smaller h-sort steps to do.[7] If the file is then k-sorted for some smaller integer k, then the file remains h-sorted. Following this idea for a decreasing sequence of h values ending in 1 is guaranteed to leave a sorted list in the end.

I CANT UNDERSTANDDDDDDDDDD
>>
>>59383451
Literally making people drop lisp because nobody wants to have anything to do with that ugly as sin piece of degenerate shit.
>>
>>59383439
Money could be use to get fun!
>>
anime thred:

>>59383468
>>
>>59383464
I agree. I am paid for by the University of Glasgow.
>>
>>59383430
Looks like what you'd see attached on pants for faggots.
Lisp alien infinitely superior, it just needs a better drawing hand

Also what the fuck does a reptile have to do with lisp? At least the alien thing has a reason
>>
>>59383456
Here's the quick rundown: shellsort a shit
>>
File: Pile-of-garbage.jpg (99KB, 900x400px) Image search: [Google]
Pile-of-garbage.jpg
99KB, 900x400px
Here is an image of Lisp I just made.
>>
>>59383464
>my language can't do xyz, so the language that can do xyz must be degenerate shit!
>>
File: rust-logo-512x512-blk.png (11KB, 512x512px) Image search: [Google]
rust-logo-512x512-blk.png
11KB, 512x512px
>Language logos/mascots
Get on my level.
>>
>>59383525
I only see Rust and Go
>>
>>59382449
>>59382395

yee, python 3 is what you should be learning
>>
we surely need to divide /dpt/ into regular /dpt/ and friendly /dpt/
>>
guys enough lets all collab on a project
>>
I want to write an app for my android phone which will allow me to send inputs over Bluetooth Low Energy to a Raspberry Pi 3.

Anyone know how to program BLE on a RPi3?
>>
File: cl.jpg (6KB, 150x150px) Image search: [Google]
cl.jpg
6KB, 150x150px
>>59383543
Talking about the logo you inbred nigger.

>>59383548
eww

Best lisp logo coming trough.
>>
>>59383557
How many times has this been suggested and how many times something was actually made?
>>
>>59383552
They're right there, "BREH"!
>>
>>59382442
first problem is using windows. don't disregard this because i'm not just shilling, windows and python kinda suck
>>
>>59383556
No. If we divide /dpt/, the two parts will surely both die.
>>
>>59383571
tox
>>
>>59383557
sure a text based encrypted chat client using RSA
>>
>>59383557
Sure, let's solve P = NP.
>>
>>59382617
>@59382589
>>
>>59383584
Tox is garbage

Suggestion: improve Tox and create a decent cross-platform interface
>>
>>59383567
>no I/O anywhere to be seen on the image
so is lisp, dare I say, /ourlang/?
>>
>>59383578
Why do you think there won't be actual programming in /fdpt/?
>>
>>59383556
I'll be sure to s*** up both.
>>
>>59383292
Wipe the tears off your face, mentally-ill boy.
>>
>>59383610
Normally you have the Read-Eval-Print Loop, shown here:
(loop (print (eval (read))))

Now just remove the Read and Print parts.
>>
File: JSON Editor.webm (177KB, 802x827px) Image search: [Google]
JSON Editor.webm
177KB, 802x827px
>What are you working on /g/?
Last night I got back into programming with a challenge to make a JSON viewer/editor in GMS. I think it turned out alright.
>>
>>59383682
>GMS
That's neat and all but why would you do this to yourself
>>
File: meme_app.png (42KB, 1918x967px) Image search: [Google]
meme_app.png
42KB, 1918x967px
>>59382347
Crypto currency price ticker made using Spring-boot, bootstrap and angularjs.
>>
>>59383682
Bretty neat.

Looks useless, though.
>>
>>59383739
>>>/g/wdg
>>
Is a program supposed to be read from top to bottom?
>>
>>59383755
left to right
>>
>>59383755
Not necessarily. In fact, usually that's a "no".
>>
>>59383456
We k-sort the list for different k to make sure we don't have to move elements linear combinations of those k later on. If the list is not very ordered to begin with this should help.
>>
>>59383755
it depends
>>
>>59383746
Spring boot backend with some default css themes so >>>/g/dpt

It stores all price fetches in a database.
>>
File: 1464460105452.jpg (25KB, 480x712px) Image search: [Google]
1464460105452.jpg
25KB, 480x712px
>>59383739
> Crypto currency
> Spring-boot
> bootstrap
> angularjs
Wew lad.
>>
>>59383755
No, but do you read a text bottom-to-top?
>>
how easy/hard is adding IPv6 support to a C app?
>>
>>59383820
It depends on what the C app do. It might be as easy as replacing inet_aton to inet_pton.
>>
File: 1485204169781.png (161KB, 618x814px) Image search: [Google]
1485204169781.png
161KB, 618x814px
>>59382603
>>
lets write some enterprise software
>>
>>59383883
no
>>
>>59383883
already on it, mate
>>
File: knuth.png (1MB, 920x599px) Image search: [Google]
knuth.png
1MB, 920x599px
Reminder that there is only one true "The Donald".
>>
I'm trying to decipher what this means exactly. I don't see anything like this under newtype in LYAH.

newtype Matrix a = Mat ((Int,Int),(Int,Int) -> a)
>>
>>59382816
Trump banned this one guy from Twitter because he kept sending him anime girl pictures.
>>
>>59383949
newtype is like data, except it only allows 1 member, and it declares that the representation should be equivalent

In this case, Matrix a is a function from pair of pairs of ints to an a, presumably the indices.
Not sure why there are four.
>>
File: Capture.png (38KB, 646x505px) Image search: [Google]
Capture.png
38KB, 646x505px
What is imutils.imlist(dir) doing?

I tried installing and importing the imutils package but it is saying imlist does not exist in that module. If i knew what that function was doing I could just write it myself.

this is for a bag of features + svm image classification algorithm. This is data pre-processing.
>>
>>59384010
here is the github that I'm using as a reference becvause I have no idea what the fuck I am doing.

https://github.com/bikz05/bag-of-words/blob/master/findFeatures.py


just trying to find out what that imlist function is doing.
>>
>>59384008
That's what I'm trying to understand. I need to use that data type to create functions, for example:
fillWith takes a pair (m, n) and an element e and produces an m × n matrix whose elements are e.
>>
>>59384076
just checked a stack overflow thing, I misread it

it's actually a pair, AND a function from a pair to an element

so presumably it's ((height, width), indexFun)
dunno why those aren't separate record members
>>
>>59384010
>>59384043
from the same repo ion imutils.py:
def imlist(path):
"""
The function imlist returns all the names of the files in
the directory path supplied as argument to the function.
"""
return [os.path.join(path, f) for f in os.listdir(path)]
>>
Currently trying to make a CHIP8 Emulator using this tutorial: http://www.multigesture.net/articles/how-to-write-an-emulator-chip-8-interpreter/

I do have a question though, for the method
setupInput() 
, what do I do?

CHIP8 has 16 keys, and the tutorial tells you which key on the keyboard goes to where, but how would I go about "binding" the keys/callbacks?
>>
>>59384010
>>59384043
direct link to the file: https://github.com/bikz05/bag-of-words/blob/master/imutils.py
>>
>>59384122
>>59384132
thank you! I don't know why I was having such a hard time finding that
>>
Given only n, how would one find p and q? (RSA shit)

My first thought was generating a list of primes <= n and then finding the right combination but I'm assuming that isn't the best option. I know having phi(n) would make it a whole lot easier to find p & q, but we are only given n.
>>
>>59384123
What language?
>>
>>59384123
It's kind of a weird thing to specify since not all APIs do input with callbacks. With something like GLFW, for example, you generally set callbacks for input, but e.g. SDL has you poll events from a queue.
>>
I know HTML, PHP, Java. Never used them to greater extent, only to tweak something here and there, maybe write some utility. Fairly confident in using them.


But. I want to build a website, a text based multiplayer RPG to be more precise, and I asked my friend from highschool about it (he got bachelors in programming and then his first job in IT about a year ago). He told me about PHP frameworks and how it's impossible to write a solid web application without them. How easier it is. Cleaner code and shit. And I accepted this and started learning Nette and later Codeigniter. Two issues:

1) The more I learn about PHP frameworks, the more I get the feeling that people who advocate for them the loudest are pseudoprogrammers; something about it simply looks like people got too lazy and can't be bothered to become a good coder. A shortcut for the weak. My friend gives me the feeling that he wouldn't be able to write a site without using that shit.
2) I struggle to learn any PHP framework. I don't know why. I've read on the concept of model-view-controller and I got the idea, but I can't implement anything, even a fucking static page. The documentation and tutorials look bloated to me and full of alien concepts that are hardly explained and I can't wrap my head around it. What I'm dealing with is this layout:
1. doing X
2. adding Y
3. ... throw your balls into the flux capacitator while reciting a 12. century poem. This produces a login form.


What do I do? Just kill myself?
>>
>>59384398
>bachelors in programming
>>
>>59383983
Because they were almost nude!
>>
>>59384427
Yeah it's a weird world we're living in
>>
>>59384398
try Java/asp.net? "web artisans" may like php/ruby/js or whatever, but c#/java are still solid choices in webdev. decent asp.net project will look good in your portfolio desu
>>
>>59384398
>>59384478
Your friend is intentionally trying to damage your brain with PHP. Do not listen to this "friend."
>>
>>59384398
Learn vibe.d
>>
Guys,

I'm on a thigh schedule and my Uni Object Orientation Programming course demanded a Java project where I need to use overload, overlap, composition, inheritance, polymorphism, static classes and methods, dynamic binding, packages, abstracts classes, interfaces, and exception handling.

Where can I find a sample "to-go" project that has all of this? Preferably with "real-world" cases.

Yeah, I know I'm not supposed to be asking for this, but it has really been hard for me to manage my time you know...
>>
>>59382608
>LITERALLY everyone who disagrees with me LITERALLY must be the EXACT same person, LITERALLY JUST because I said so, I AM KING, I AM GOD, MY WORD IS LAW

wow dude great argument, you really activated my almonds.
>>
>>59384539
>OOP
>>
>>59384539
Blocks world AI project.
>>
File: 1328140568318.jpg (30KB, 355x342px) Image search: [Google]
1328140568318.jpg
30KB, 355x342px
>>59384535
Elaborate some more pls?
>>
>>59384398
Typically web frameworks solve problems you never knew you had until you've gone through the motions the normal way a few times. just drop the frameworks and do it yourself, it might not be as clean or as artisanal but you'll learn a heckovalot more
>>
#include <iostream>

enum Values
{
VALUE1 = 0x100,
VALUE2 = 0x1337,
VALUE3 = 0x1338
};

Values firstItem[2]
{
VALUE1, VALUE2
};

Values secondItem[3]
{
VALUE1, VALUE2, VALUE3
};

Values arrayOfItems[2] = {
*firstItem, *secondItem
};

int main()
{
for(auto &item : arrayOfItems)

return 0;
}


I need to iterate the enums in a certain order, such that: arrayOfItems -> firstItem -> VALUE1 -> VALUE2 -> secondItem -> VALUE1 -> VALUE2 -> VALUE3 -> end of loop

Is there a better way to do this, /g/?
>>
>>59384539
Write the fucking thing yourself. It takes maybe an hour if you know what you're doing.
>>
>>59384398
1. Stop using PHP. Use Java or something instead.
2. Frameworks allow you to write less code and get more results, make your code more maintainable, usually have great performance because they're built/maintained by very smart people. They also do a lot of things out of the box that a noob might not think of. USE FRAMEWORKS
3.
>calling friend stupid for using a framework
>can't even figure out how to use the framework yourself
You know, maybe programming isn't for you.
>>
what is a framework?
>>
>>59384539
write a fun project and when you're done check if you used all thee memes required. If you didn't you can propably shoehorn them in in some way.
>>
>>59384701
what is a frame? what is a work?
>>
>>59383602
You don't solve P vs NP, you either manage to get out of the problem or waste your life on it.
>>
>>59384822
t. brainlet
>>
>>59384701
Depends on what you mean by "framework".
>>
what
>>
>>59384539
>thigh schedule
>>
>>59384853
t. marxoid
>>
>>59384610
Are you trying to output what flags are enabled? Such that the output would look like this:
firstitem-
flag 100
flag 1337
seconditem-
flag 100
flag 1337
flag 1338


If so, I would suggest using binary flags (powers of 2) like this:
enum Values
{
VALUE1 = 0x01,
VALUE2 = 0x02,
VALUE3 = 0x04
};

void main()
{
int val1 = VALUE1 | VALUE2;
int val2 = VALUE1 | VALUE2 | VALUE3;

int valuearray[] = { val1, val2 };

for (auto i : valuearray)
{
printf("Variable\n");
if (i & VALUE1) printf("\tVALUE1\n");
if (i & VALUE2) printf("\tVALUE2\n");
if (i & VALUE3) printf("\tVALUE3\n");
}
_getch();
}


Gives you this output:
Variable
VALUE1
VALUE2
Variable
VALUE1
VALUE2
VALUE3
>>
how do i do it in haskell
>>
>>59384939
do what
>>
>>59385008
a general purpose AI waifu
>>
>>59385073
get a real gf
>>
>>59384539
Do your own homework, faggot.
This isn't even hard. Just make stupid useless shit up like abstract Animal classes.

If they say it's too useless, you tell them that they should have defined a project outline worth a damn.
>>
>>59384359
C++

>>59384387
So could I do something like using GLFW to get callbacks and SDL for graphics/audio?

Also, what does 'input with callbacks' mean?
>>
File: AthOR0U.png (176KB, 441x421px) Image search: [Google]
AthOR0U.png
176KB, 441x421px
Starting with SICP. Wish me luck.
>>
>>59382404
>posting another thread while there already is one
>reporting it because it doesn't have muh anime
Grow up.
>>
>>59382404
>reporting an on-topic thread
>announcing your reports

you're a bit fuckin daft eh roight cunt?
>>
>>59383755
Think it depends on the language. In something like c, the compiler will fail if you call a function before declaring it but in javascript you are allowed to declare and call functions in any order. And then in HTML/css the order the browser reads is from right to left or something.
>>
>>59385191
>>59385208
Stay frustrated: >>59383468
>>
>>59382347
Rate my Haskell:
module Heap (Heap(..)) where
import Data.MonoTraversable

class (Ord (Element h), MonoFoldable h, Monoid h) => Heap h where
merge :: h -> h -> h
pop :: h -> Maybe ((Element h), h)

singleton :: Element h -> h
insert :: (Element h) -> h -> h

buildheap :: (MonoFoldable mono, Element mono ~ Element h) => mono -> h

insert x xs = merge (singleton x) xs
singleton x = insert x mempty

buildheap xs = ofoldl' (flip insert) mempty xs


instance forall h. (Heap h, Ord (Element h)) => MonoFoldable h where
ofoldl' operator init heap =
case (pop heap) of
Nothing -> init
Just (popped, newheap) ->
let acc = operator init popped in
seq acc $ ofoldl' operator acc newheap

ofoldr operator init heap = go heap where
go heap =
case (pop heap) of
Nothing -> init
Just (popped,newheap) -> operator popped $ go newheap

ofoldMap f = ofoldr (mappend . f) mempty
ofoldr1Ex op heap =
case (pop heap) of
Nothing -> error "ofoldr1Ex should return a Maybe!"
Just (popped,newheap) -> ofoldr op popped newheap
ofoldl1Ex' op heap =
case (pop heap) of
Nothing -> error "ofoldr1Ex should return a Maybe!"
Just (popped,newheap) -> ofoldl' op popped newheap


Example of instance declaration:
module LeftHeap (LeftHeap) where
import Heap
import Data.MonoTraversable

data LeftHeap a = Empty | Node a (LeftHeap a) (LeftHeap a)

type instance Element (LeftHeap a) = a

instance (Ord a) => Monoid (LeftHeap a) where
mempty = Empty
mappend = merge

instance (Ord a) => Heap (LeftHeap a) where
singleton x = Node x Empty Empty

merge Empty x = x
merge x Empty = x
merge heapx@(Node x xs1 xs2) heapy@(Node y ys1 ys2)
|(x >= y) = Node x xs2 (merge xs1 heapy)
|otherwise = Node y (merge ys2 heapx) ys1

pop Empty = Nothing
pop (Node x heapA heapB) = Just (x, merge heapA heapB)
>>
>>59385150
Just don't use callbacks if you don't want to use an API that uses them. All it means is that you get input via a callback that is called when you poll for events instead of looping through a queue.
>>
>>59385286
Example of use:
Example of use:
import Data.MonoTraversable
import Heap
import LeftHeap
import BinHeap


heapsort :: forall mono a. (a ~ (Element mono), Ord a, MonoFoldable mono) => mono -> [a]
heapsort xs = ofoldl' (flip (:)) [] (buildheap xs :: BinomialHeap a)

heapsortr :: forall mono a. (a ~ (Element mono), Ord a, MonoFoldable mono) => mono -> [a]
heapsortr xs = otoList (buildheap xs :: LeftHeap a)

>>
where should I learn from about design patterns?
>>
>>59385312
>>
>>59385312
AbstractBeanSuperFactoryImpl
>>
working on the next rust, lads
>>
>>59385286
>>59385303
Trash out of 10.
>>
>>59385312

https://sourcemaking.com/design_patterns

http://www.yegor256.com/2016/02/03/design-patterns-and-anti-patterns.html
>>
>>59385286
cute, but stop pattern matching on maybe
>>
>>59385394
>yegor256
kek
>>
>>59382395
Your question was kind of already answered, but why wouldn't you just do this?

if 'x' in my_list:
my_list.remove('x')
>>
>>59385394
yegor256
Oh boy.
>builder bad
>null object good
This guy.
>>
>>59385443
https://github.com/yegor256/eo
>>
File: Crazy Deeds Done The Hard Way.jpg (67KB, 1280x720px) Image search: [Google]
Crazy Deeds Done The Hard Way.jpg
67KB, 1280x720px
>>59385177
Good luck, anon!

>>59385298
Thanks!
>>
>>59385396
What do you suggest instead? If you can find a cleaner alternative for the implementation of the MonoFoldable instance I'm all ears.
>>
>>59385423
>>59385443
Reminder that he can't even traverse a binary tree:
http://www.yegor256.com/2017/02/21/say-no-to-google-recruiters.html
>>
>>59385476
Oh wow. I know this story, but I didn't realize it was him. That's even better.
>>
>>59385465
rather than using case, use the maybe function

maybe :: b -> (a -> b) -> Maybe a -> b

e.g.

  go heap =
case (pop heap) of
Nothing -> init
Just (popped,newheap) -> operator popped $ go newheap

becomes
go = maybe init (\(popped, newheap) -> operator popped (go newheap)) . pop
>>
This is probably pretty basic but I can't figure out how to do it.

In Python how do you iterate over all possible combinations of elements from two lists. Not iterating in parallel.

something to the effect of

In:
for i,j in ['a','b','c'],['A','B','C']:
print i+j

Out:
aA
aB
aC
bA
bB
bC
cA
cB
cC
>>
>>59385486
And why is that better?
>>
File: 1451320824538.jpg (30KB, 542x296px) Image search: [Google]
1451320824538.jpg
30KB, 542x296px
>>59385476
That's Laura Schenck-tier!
>>
>>59385493
more concise, less syntactic and whitespace noise
>>
>>59385488
zip
>>
>>59385488
>>59385522
Fuck, I mean nested loops.
>>
>>59385177
Did you buy the printed book or are you reading it online from the MIT website?
If it's the latter, I strongly recommend using this: http://sarabander.github.io/sicp/
It's the same, but beautifully typeset with LaTeX for your pleasure.
>>
>>59385486
Thanks! Will do, I prefer functions over special syntax for control flow when possible, it feels more Haskelly.
>>
>>59382791
that shit is outdated, autist
>>
>>59385246
Animes don't frustrate me. If they did, I wouldn't be here.
What frustrates me is people over-reacting to this shit, like "Oh, this thread has no anime in the OP, let's boycott it and start another one, wee!"
This is not a grown man's attitude.
>>
>>59385536
Yeah I was thinking that but that seems like it could be slow, is there any way of doing it with list comprehension or something?
>>
>>59385488
import itertools

L1 = ['a', 'b', 'c']
L2 = ['A', 'B', 'C']

print('\n'.join([''.join(v) for v in itertools.product(L1, L2)]))


[~] » python test.py 
aA
aB
aC
bA
bB
bC
cA
cB
cC
>>
>>59385543
Thanks anon. The link you posted is a much nicer read. I don't think the MIT website is meant to be looked at on a 16:9 screen. The text is way too wide.
>>
>>59382842
uuuu
>>
Is there a short and concise book on C++?
Something that covers the main points of C++ in a few dozen pages? Such as when it's best to use .h etc

A 1,000 page book isn't something I will ever use
>>
>>59385733
The C Programming Language by Brian Kernighan and Dennis Ritchie
>>
>>59385741
reading_comprehension.cpp
>>
>>59385648
Looks good, thanks.

I'm surprised it needs a module to do this though.
>>
>>59385733
>C++
>in a few dozen pages
Doesn't exist, C++ is the YOOGE language.
>>
>>59385741
Dumb C toddler
>>
>>59385766
You don't need the itertools to perform a cartesian product but why reinvent the wheel if the standard library provides an implementation. You're using Python and not C after all so the standard lib is actually useful.
>>
Reminder that it's
"Hello, world!"
not
"Hello world!"
>>
>>59385550
>>59385486
Refactored into:

instance forall h. (Heap h, Ord (Element h)) => MonoFoldable h where
ofoldl' operator init = maybe init (\(popped, newheap) ->
let acc = operator init popped in
seq acc $ ofoldl' operator acc newheap) . pop

ofoldr operator init heap = go heap where
go = maybe init (\(popped,newheap) -> operator popped $ go newheap) . pop

ofoldMap f = ofoldr (mappend . f) mempty
ofoldr1Ex op = maybe (error "Empty heap!") (\(popped,newheap) -> ofoldr op popped newheap) . pop
ofoldl1Ex' op = maybe (error "Empty heap!") (\(popped,newheap) -> ofoldl' op popped newheap) . pop
>>
>>59385768
That's why I need something small and concise covering only the basics.
I can already program, and anything more advanced I'll learn on a need to know basis.
>>
>>59385823
it's worth pointing out some of these lambdas could be where clauses
>>
>>59385815
Fair enough, cheers again.
>>
>>59385823
>>59385835
plus
 ofoldr operator init heap = go heap where
go = maybe init (\(popped,newheap) -> operator popped $ go newheap) . pop


->

ofoldr operator init heap = maybe init (\(popped,newheap) -> operator popped $ go newheap) . pop


or
ofoldr operator init heap = maybe init go . pop
where go (popped, newheap) = operator popped (go newheap)
>>
>>59385853
whoops, in the second two, remove the "heap" parameter, i eta reduced
>>
>>59385834
I say there's nothing small.
>>
>>59385875
Well that sucks.
I guess I'll never read a book on C++, just google things i want to know
>>
>>59385921
I told you to go read K&R.
There's nothing about the C++ language that's small and concise.
You're describing C.
>>
>>59385921
Check this link: http://www.4p8.com/eric.brasseur/cppcen.html
>>
>>59385476
whiteboard interviews have to die though
>>
So I'm reading a book on SFML
And at some point it start talking about template
As a good little sheep I copy the code and eventually make some adjustement so shit can compile

And then I get this:
[error] 'ActionTarget' is not a template type

with this as problematic code:
template <typename T=int>
class ActionTarget

I don't get what's wrong, mostly because I'm still new and never had a proper explanations on template(and a lot of other things I think)

I've been stuck on this for hours now trying various solution I found online with nothig working

Also how do I do special code encasement like>>59385853 for future reference
>>
>>59385853
I'm not sure if that works. Note the recursion.
>>
>>59386021
<code>
but square brackets
</code>
>>
>>59386055
Thanks
>>
how would i make my web app read data from a csv file thats on a different server? as long as im networked to the drive i shouldnt have any problem right?
>>
>>59386049
Oh, whoops, I didn't notice
You can certainly move the lambda into the where clause though, and you can eta-reduce too

ofoldr operator init = go where
go = maybe init handle . pop
handle (popped, newheap) = operator popped (go newheap)
>>
File: spanish.jpg (31KB, 540x533px) Image search: [Google]
spanish.jpg
31KB, 540x533px
can someone explain to me what a high water mark is in node streams? It's not really explained anywhere in the docs or stackoverflow.
>>
>>59386049
>>59385853
Specifically, it needs to pop & pattern match on each recursive call.
>>
>>59386091
And in this case, you could inline the definition of go, but this way it's more easily optimised by the compiler (rather than recursively calling ofoldr with the same args)
>>
:code:

attempt

:stopcode:
>>
C would be so much better if ({}) syntax was standardized.
>>
>>59386151
initializer lists?

that's standardized
>>
>>59386151
Do you mean that GCC extension?
>>
>>59386021
Help?
>>
>>59386183
no the gcc extension.
https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
>>
>>59386009
Someone didn't get the job he wanted...
>>
>>59385819
In K&R 2nd ed. it's
"hello, world\n"
.
>>
>>59386208
I've never been to one like that. But I know for sure I wouldn't be able to even tie my shoelaces in front of a board.
>>
>>59386245
Good.
The vocative comma is an endangered rule, threatened by barbarians.
>>
File: 1440246538429.png (304KB, 722x768px) Image search: [Google]
1440246538429.png
304KB, 722x768px
n = 1
while n < num + 1
body
n += 1

or
for n in range(1, num + 1)
body
>>
while (fgets(buffer,  fileCounter, fp) != NULL){
stripNewline(buffer);
printf("%s\n", buffer);

wordListAdd(myWordList, buffer);
fileCounter++;
}
[\code]

Can anyone help explain why this neither successfully adds line-by-line to a list I've created? It won't even print, and the print is only in there so I can make sure that the txt file is actually being processed
>>
>>59386269
'for' is syntactic sugar for 'while', but is more readable.
>>
>>59386091
Followed your adviced, and refactored ofoldl' into:

  ofoldl' operator init = go init where
go acc = seq acc $ maybe init (recur acc) . pop
recur acc (popped, newheap) = go (operator acc popped) newheap
>>
How good is your memory anons?
http://www.humanbenchmark.com/tests/memory
>>
File: b49.gif (1MB, 680x680px) Image search: [Google]
b49.gif
1MB, 680x680px
ANIME FAGS GET OUT REEEEE
>>
>>59384582
PHP is not a programming language. It's an HTML template language, that had shit piled on top, until it looked something vaguely resembling a programming language. People that advocate PHP are not programmers. Pic related - a quote from the creator of PHP.
>>
File: 827.png (250KB, 680x638px) Image search: [Google]
827.png
250KB, 680x638px
I'm making a game!
>>
>>59386467
same
>>
>>59386428
Oops, meant:
ofoldl' operator = go where
go acc = seq acc $ maybe acc (recur acc) . pop
recur acc (popped, newheap) = go (operator acc popped) newheap
>>
>>59386443
FUCK OFF NORMALFAG REEEEEEEEEEEEEE
>>
>>59386461
At least he is honest.
>>
>>59386461
Some Ruby/JS pajeet is buttmad that PHP is more popular than his little toy-"language"...
>>
>>59386493
don't post anime girl pictures pls
they make me cry because i acnt be an anime giel
>>
>>59386320
>syntactic sugar
>more readable
Says who? What if you like your coffee black? Why do I have to conform to some arbitrary standard just because retards can't handle code without syrup oozing out of it?
>>
File: programming socks.png (338KB, 1140x813px) Image search: [Google]
programming socks.png
338KB, 1140x813px
>>
>>59386493
what happened to her feet lmao
>>
File: 0ca.jpg (261KB, 900x900px) Image search: [Google]
0ca.jpg
261KB, 900x900px
>>59386493
>>
>>59386513
Killing yourself and sucking cock are also quite popular activities. Why aren't you doing that?
>Ruby/JS
>implying
>>
>>59386269
for keeps the unnecessary variable 'n' out of the scope. much cleaner
>>
>>59386529
Dumb frog poster.
>>
>>59386534
>implying he doesn't suck cocks
>>
File: c37c75d79ceacb29e9c72981f0161ff1.jpg (153KB, 640x1136px) Image search: [Google]
c37c75d79ceacb29e9c72981f0161ff1.jpg
153KB, 640x1136px
>>59386526
Feet cancer because of frog posters.
>>59386514
>>59386529
>>
File: VQSucsH.png (228KB, 858x725px) Image search: [Google]
VQSucsH.png
228KB, 858x725px
>>59386549
>>59386572
FUCKING PEDERPHILE GET OUUUUT
>>
>>59386572
post more anime giels
i lost my special pack
>>
>>59386597
Here, have a busty one.
>>
>>59386597
IMMA FIND OUT WHERE UR MUM LIVES
>>
>>59385733
The C++ Programming Language, 4th edition, by Bjarne Stroustrup. (Addison-Wesley Professional, 2013)

>>59385741
It's true that C++ is mostly compatible with C, but 1. it's not 100% compatible, and 2. its creator, Bjarne Stroustrup, actually discourages thinking about C++ in C. C and C++ have very different approaches to programming.
>>
>>59386534
I do suck cocks, you got a problem with that?

>>59386558
>he
>>
File: 1454876662117.jpg (322KB, 1280x720px) Image search: [Google]
1454876662117.jpg
322KB, 1280x720px
>>59386597
>>
>>59386092
It's like the size of the buffer.
>>
Post stupid reasons why you didn't try to learn languages. I'll start:

>be used to C
>try learning Python, heard it's good
>there are actually two different versions, not compatible with each other
>thatsnottoobad
>try to use two print statements
>find out they automatically add a \n
>fuck this shit, I'm out.
>>
>>59386904
Perl is better
t. Perl user who started learning Python
>>
>>59386904
print "fucking retard",
>>
>>59386904
sys.stdout.write
>>
>>59386904
>>59387023
print('hello', end='')
>>
>>59386904
>be used to C
Found your problem. C is corrosive to brain and C toddlers are stupid out of the box.

$cat >test.py
print "C",
print " toddler"

$ python2 test.py 
C toddler
>>
>>59386904
>CS retards say Python is good
>It has dynamic typing
>Dropped
Oh wait, I misread the prompt and posted a good reason.
>>
>>59386151
The more I write C, the more I think that Ritchie was right and that allowing variable declaration anywhere like in C99 is a stylistic mistake, because it doesn't enforce a clear separation between the operation of stacking variables for future use and their actual use.
In another way, C99 may permit declaration on the fly, which is very practical for quick coding, but adopting this style doesn't reflect how it's really done under the hood.

I guess the GCC extensions and all the C99 novelties have the same pros and cons.
>>
>>59387110
P A S C A L
A
S
C
A
L
>>
>>59387009
I know!

>>59387023
char *stupid = "stupid";
printf("I said \"%s\" reasons."
"Of course I know there is a way to do what I wanted, "
"hence why it is a %s reason.\n",
stupid, stupid);


By the way, compile-time string concatenation is one of the reasons I like C. It allows me to have all me source files not exceed 79 columns.
>>
>>59387110
Ada want a mistake
>>
>>59387126

Gotta love how Pascal has a very specific place for everything.
>>
>>59387138
>string concatenation
speaking of, write a program in C that takes any number of arguments as strings, and returns the pointer of the concatenated arguments
>>
>>59387138
stupid = "stupid"
print("""I said "{}" reasons. """
"""Of course I know there is a way to do what I wanted, """
"""hence why it is a {} reason.""".format(
stupid, stupid
))
>>
>>59386291
>fgets(buffer, fileCounter, fp)
>fileCounter
The second argument is supposed to be the max size of the buffer.
I imagine that this variable is supposed to be 0 on the first time the loop is called, so fgets isn't even going to read anything and is just going to return NULL immediately.
>>
>>59387177
That's what we call bad code.
>>
>>59387200
That's what we call dodging
>>
New thread:
>>59387221
>>59387221
>>59387221
>>
>>59387177
>program
>returns a pointer
Do you mean a function?
>>
>>59387110
>allowing variable declaration anywhere like in C99 is a stylistic mistake
You're stupid.
Intermixing declarations and statements allows for variables to be declared much closer to where they are used, reducing their scope and making the program easier to reason about.
It also allows you to have const variables that are actually useful.
Thread posts: 314
Thread images: 54


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