[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: 312
Thread images: 31

File: 09-16-26-Hackers-With-An-Agenda.jpg (809KB, 1000x749px) Image search: [Google]
09-16-26-Hackers-With-An-Agenda.jpg
809KB, 1000x749px
/dpt/ daily programming thread

What are you working on, /g/?


Previous Thread: >>55180495
>>
>>55188975
First for D
>>
>>55188975
>Created before the bump limit
Report this thread.
Do not post in this thread.
>>
File: himegoto considered harmful.png (1MB, 1000x1400px) Image search: [Google]
himegoto considered harmful.png
1MB, 1000x1400px
Types aren't good enough
Are refinement types good enough?
>>
>>55189015
Bump because fuck the shitty trap meme
>>
>>55189016
Fuck off you degenerate sack of shit
>>
What's the best programming language you've ever worked with?
>>
>>55189062
PHP
>>
>>55189062
Javascript by far. There isn't even a real contender.
>>
>>55189062
C
>>
>>55189062
C
>>
>>55189080
>>55189086

MAKE UP YOUR FUCKING MINDS

>>55188958
>>55188932
>>55188930
>>
>>55189062
C#
>>
>>55189062
Python, versatile and quick to develop in, even if it's just a PoC or prototype.

Also, piss easy to learn.
>>
>>55189080
>>55189086
void bait_loop(bait_type x) {
bait_type old = x;
while (old == x--) {
x--;
}
}

compiles to
bait_loop:
.L2:
jmp .L2

why is this allowed, /g/?
>>
>>55189099
C is the only programming language
>>
I've never really encountered prototyping.

I was just told my JS array is a pseudo array and I dont understand. Where can I read about this?

Is it similar to polymorphism / inheritance in OO languages?
>>
>>55189154
JS is a pseudo programming language, therefore anything you make in it is a pseudothing
>>
>>55189134
Because they are semantically equivalent.
>>
File: 1464823306282.png (5KB, 270x175px) Image search: [Google]
1464823306282.png
5KB, 270x175px
>>55189169
Actually, this is a common misconception.
A language is defined as "the method of human communication, either spoken or written, consisting of the use of words in a structured and conventional way."
Javascript is neither structured nor conventional.
Javascript is a programming pseudo-language.
>>
>>55189062
C# for large scale shit
python for small stuff
c++ when i need to do shit cross platform without forcing the user to download a python interpreter or similiar
>>
>>55189062
Lua
>>
>>55189134
>>55189175
How the fuck are those equivalent?
>>
>>55189062
Hoon or bust.
>>
>>55189134
http://lemire.me/blog/2016/05/23/the-surprising-cleverness-of-modern-compilers/
>>
>>55189015
>>55189016
Fuck you trapfag
>>
File: plz_gibe_strong_ai.jpg (161KB, 870x722px) Image search: [Google]
plz_gibe_strong_ai.jpg
161KB, 870x722px
>mfw

https://openai.com/blog/openai-technical-goals/
>>
>>55189286
Kill yourself.
>>
>>55189212
Both don't do anything at all in the end, so they are pretty much equivalent.
>>
>>55189296
Why are you even angry, plebe ?
>>
>>55189316
>don't do anything
>loop forever
>>
>>55189016
Refinement types are just types with constraints.
>>
>>55189329
How does it loop forever?
>>
>>55189430
>>55189134
>>
>>55189134
overloaded == or -- operator
>>
>>55189498
>C
>overloaded operators
>>
>>55189503
You never said it was C
What type is bait_type
>>
>>55189514
>You never said
>I can't follow a reply chain
>>
>>55189526
>I can't follow a reply chain
Maybe you should learn then
>>
>>55189514
>never said it was C
>>55189080
>>55189086
>>
For a beginner, is any sufficiently-large project useful for a portfolio to get out of NEETdom?

I really want to make a simple 2D platformer in C++. Assuming it's not complete garbage, is it enough to get hired for an undergrad job?
>>
>>55189544
>damage control
>>
>>55189498
>overloaded
webshits everyone
>>
>>55189635
Name a web language with overloading you stupid cunt.
You're that twerp (I believe that's the correct pronoun for people under the age of 12) that loves Java but calls other people Pajeet, aren't you? And now you're calling people webshits, people that don't do web. Do you even speak English you daft indian twat?
>>
is there still a market for perl?
>>
>>55189651
Do you even need to ask?
>>
File: smug_sakura.jpg (29KB, 337x404px) Image search: [Google]
smug_sakura.jpg
29KB, 337x404px
>2016

>He writes dumbware that doesn't learn from experience
>>
>>55189646
>under the age of 12
You shouldn't be here then.
>>
File: 1463612034039.jpg (188KB, 1680x910px) Image search: [Google]
1463612034039.jpg
188KB, 1680x910px
>>55189682
>quote mining
>>
>>55189646
>pretending not to be a webshit
we know tho
>>
>>55189498
>C
>overloaded operator
wew laddie
>>
>>55189614
bump for interest, tell me if you find an answer anon
>>
in Python is it worth it as an exercise to attempt to write your own version of some existing functions?
>>
>>55189771
#define == ||
>>
how does something like the linux kernel prevent naming conflicts without namespaces?
>>
>>55189830
by not using the same function names
>>
>>55189849
yea, but how do you know some other asshole didn't already take the name you are about to use?
>>
>>55189815
>== is an identifier
you can't be this retarded
>>
>>55189854
grep
>>
>>55189890
Why is C so shit?
>>
>>55189915
>I'm a confirmed retard
>C is shit tho
webcuck, please
>>
File: 1453656893900.png (1021KB, 870x717px) Image search: [Google]
1453656893900.png
1021KB, 870x717px
>>55189933
>webcuck is a subtype of valid arguments
>>
>>55189945
>weeaboo shit
You're not entitled to an opinion.
>>
>>55189908
>everytime I write a function, I need to run grep

Cshits pls
>>
>>55189959
>use a weeaboo site
>call others weeaboo

>>55189952
pseudo-code
def func(arg1):
def func1(arg2):
/* */
return;
return func1
>>
>>55189963
>everytime I write a function, I need to run grep
sounds like you're retarded
>>
In python should I use
def func(*args):
/* */
return

func("arg1", "arg2")


or

def func(args):
/* */
return

func(["arg1", "arg2"])


?
>>
Does anyone here have a pdf of "Fundamental 2D Game Programming with Java by Timothy Wright? I live in a shit-tier country so buying it hard since I won't find it Paperback and Shipping it from somewhere will be expensive as fuck.
>>
>>55189972
>I'm mentally ill
>this site is full of us tho
>>
File: 33.jpg (15KB, 300x100px) Image search: [Google]
33.jpg
15KB, 300x100px
>>55189982
>>55189972


>>55190007
This site was invented for anime loving autists, and by coming here you've proven yourself to be an anime loving autist. Congratulations.
>>
>>55189982
Depends what structure your argument requires.

I just use same defaults style

def func(arg1, arg2=False):
print(arg1, arg2)

func(["data"], arg2=2)
>>
>>55189646
Python is able to overload operands to my knowledge. You specified web languages and python is becoming quite prominent in the web scene.
>>
>>55189793
Sure if you want to get acclimated to the idioms of Python.
>>
>>55190091
I didn't know that because I'm not a webshit
>>
File: popularity of oop explained.png (107KB, 1163x674px) Image search: [Google]
popularity of oop explained.png
107KB, 1163x674px
Who /oop/ here?
>>
>>55190127
>not a webshit
>Name a web language
anon...
>>
>>55190025
>admitting to be mentally ill
>>
>>55190127
Woah there. I'm just a random guy chiming in on your conversation. I don't touch web, to much shit going on for me to break.
>>
>>55190175
I didn't name it

Maybe you should've listened when >55189526 said you can't follow a reply chain

>>55190192
So you don't disagree?

>>55190196
I was just getting back at the other guy
>>
>>55190127
There's no need to lie on the internet.
>>
Best free tool to make graph from database?
Something where you can easily see the relations and filter tables interactively
>>
>>55190127
>doesn't know C
>not a webshit tho
please
>>
>>55190230
I use C++ because it's not the 1980s any more, it's current year
>>
>>55190209
>can't follow a reply chain
Maybe you should learn then
>>
>>55190239
>don't know C
>I use C++ tho
webshits everyone
>>
>>55190239
>I use C++
Are you mentally ill?
>>
>>55190242
You're right, maybe you should learn

>>55190251
C++ isn't a web language

>>55190267
I use it as little as possible
>>
>>55189134
This is like asking dpt to average 2 numbers.
>>
>>55190299
I thought we were done talking about unsolvable problems
>>
>>55190276
>You're right
I know
>>
>>55189614
they don't care about games

they want applications that interact with databases, database designs, maybe through in some RESTful server as well

also learn Javascript shit like angular, express, etc.
>>
>>55190303
>unsolvable
webshits actually believe this
>>
File: 1466355216727.gif (1MB, 480x270px) Image search: [Google]
1466355216727.gif
1MB, 480x270px
>>55190314
You're welcome anon

>>55190337
Average 2 integers.
Do it faggot.
>>
>>55190337
>>55190339
Oh boy here we go
>>
>>55190339
>teach me how
>I'm mentally ill tho
would be pointless
>>
File: averaging 2 integers.png (2KB, 512x86px) Image search: [Google]
averaging 2 integers.png
2KB, 512x86px
>>55190339
done
>>
Are linked lists better than arrays?
>>
File: Python_logo_and_wordmark.svg.png (7KB, 260x77px) Image search: [Google]
Python_logo_and_wordmark.svg.png
7KB, 260x77px
So, I'm learning Python. It's my first programming language.

I'm having a hard time understanding everything.

Any advice? Tips? Stuff I can do to get it down better?
>>
>>55190415
No, and they never will be.
>>
I am trying to slim down and gain a the trust and love of a cumslut.
That said, I am a bit stumped.
I have a solid diagram for separating numbers by their digits and calculate their middlenumbers (?)
So 987 is 9+8+7=24
Problem is the following:
How can I make Java calculate the modulo and division of any number I enter and save it?
Do I use arrays for that?

That is my step for step algorithm:
Enter a number (use scanner)

Check if positive, if not break

If positive, calculate length with string.valueof (entered number).length.
Assign it to int digits

Loop:

Int exponent = 10^(--digits) Ex: 10^(--3)

Divide entered number by exponent Ex: 987/100 =9
Save 9 for middlenumbers.

Modulo by 100 Ex: 987%100=87
Save 87 for loop calculations

Repeat until digits is less than 0.


System.out.println (9+8+7)

How do I achieve that?
>>
>>55190436
Sounds like you know what you're talking about.
>>
Should I learn asp.net?
>>
>>55190457
nice blog
>>
>>55190415
>>55190462

Every next element of a linked list means your CPU has to jump to (an effectively random part of) memory
>>
>>55190364
see you on the bench patent thief
>>
>>55190480
Not an issue insert and remove.
>>
>>55190562
Yeah, why would you ever want to access more than one element of a list?
>>
>>55190421
You are not going to get any replies unless you are more specific. The generic advice for "I don't understand" is to keep practising and research alternative tutorials if the ones you're reading are not adequate.
>>
What's the command in gdb to continuously print out values of certain variables? I know I can just say print, but how do I make it print out values after every step?
>>
>>55190562
It is if you have to find the element you want to remove or the position you want to insert to.

Unless you're implementing something like a deque (where the insertions and deletions are happening at a predefined location), you should avoid linked lists.
>>
>>55190657
>have to find the element you want to remove
No, generally you already have the element and you want to keep insertion/removal as fast as possible.
>Unless you're implementing something like a deque
I prefer implementing deques with arrays.
>>
>>55190421
Don't use Learn Python the Hard Way. It's shit, takes way too long to teach, and the author is an ass.

If you don't understand Classes, I'd recommend Derek Banas' video on them. His other videos are excellent as well.
>>
>>55190713
I've been using Learn Python the Hard Way. Is there a better alternative? Like CodeAcademy?
>>
>>55190755
I've heard good things about Dive into Python. And again, Derek's videos are good for beginners, though can be a bit fast.
>>
>>55188975

How are IP addresses and ports related? What even is a port?

I'm having a hard time understanding the basics of networking because every explanation is so vague.
>>
>>55190755
Oh and jesus fuck don't use codecademy. It teaches you nothing but syntax. I'm amazed it's even still being recommended.
>>
Pi zero, board only is in stock in two stores

https://thepihut.com/products/raspberry-pi-zero
https://shop.pimoroni.com/products/raspberry-pi-zero

I've been trying to cop one for literally months.
>>
>>55190755
You should start with C, don't fall for the 'C is hard' meme. C is a simple language and you'll gain invaluable general programming experience and knowledge.
>>
>>55190421
When you start programming, it's easy to get overwhelmed.
It's best to think of it like doing mathematics, because that's what programming is pretty much based on.
Variables are like variables in mathematics: you assign a value to x, and then you can use x instead of that value.
But in mathematics you normally only have numbers, where in programming you have integers, floats, strings, and boolean values.

Then there's functions which are exactly like in mathematics :
f(x) = x + 1 is a mathematical function that takes the argument x and returns x+1, but in programming you need a little more syntax, so you have
def f(x): return x+1
where def means define. And then you have to call it by writing f(x) just like in math, where you might have something like this:
h(x):= f(x) + 1
Which means h(x) returns x+1+1

There's also things like if-conditions and while-loops but those should be easy enough to understand.

There's also " classes" but you should ignore those for now. That is an advanced topic.

Basically if you're good at math, it should be easy, and if you suck at math kill yourself
>>
File: Kandr.png (107KB, 792x1023px) Image search: [Google]
Kandr.png
107KB, 792x1023px
>>55190893
Don't fall for the "K&R is good" meme either.

People don't consider it a joke, but seriously this thing has no place in the modern world. It uses needlessly complex language, outdated programming techniques, examples which are barely helpful, and often don't run on new PCs.
>>
>>55190899
>in mathematics you normally only have numbers, where in programming you have integers, floats, strings, and boolean values

integers - integers
floats - rationals
booleans - booleans
strings - free monoids
>>
>>55189062
best for working with, probably OCaml cause the tooling is awesome and the language is great, but it's not the _best language_ that I've worked with (i.e. on paper). but since tooling for Haskell or Idris isn't as nice I think OCaml is better _to work with_
>>55189646
PureScript
>>
>>55190797
Ip addresses are for the communication between computers over the Internet.
Ports are for the communication of processes (programs).

Imagine a computer is a city, and a program running on the computer (like a Web server, email server, or whatever) is a house.
The ip address is the zip code of the city, and the port is the street address.
>>
>>55190929
>It uses needlessly complex language
lmaooo
>>
>>55190938
>ocaml
>2016 + 1 - 1
>no modular implicits
>>
>>55190964
I can live with it for now, modules are so much nicer than type classes that it's worth it
>>
>>55190949

This makes sense.

But what if multiple computers are on the same network?
>>
>>55191047
Then theu have different ip
>>
>>55190955
eyyy because c
>>
>>55191063

So does the network itself have any identifying information
>>
>>55190421
Keep working at it. Python the Hard Way is a great introduction - it pushes you right in. Do Codeacademy as well and keep coding. Try stuff out.

Understand that coding is a craft; you must become a craftsman.

Here's an algorithm to become good:

Solve problems and create stuff.
Keep doing it.

Read this,

It takes a lot of effort and patience to be learn programming. People are generally too incontinent for this stuff.
>>
>>55191161
>incontinent
you had me right up til here
>>
>>55191137
Yes. First bits of the set of ip it can contain. Look for netmask
>>
Who vim master race here?
>>
>>55191346
We NeoVim nigga.
>>
>>55191346
>V ⇒ ¬M; V ^ M
Nobody
>>
>>55191364
Found the emacs fag
>>
File: 1442284683769.gif (3MB, 658x800px) Image search: [Google]
1442284683769.gif
3MB, 658x800px
>30 minute technical interview at small start up
>mfw never done one before
>>
∀ vim_users ∄ intelligence
>>
>>55191435
Autism
>>
I want to make it so that with each tap a shape changes between black and white in xcode/swift. should I use a button or something?
This is what I tried but it doesn't work

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
/* Called when a touch begins */

for touch in touches {
_ = touch.locationInNode(self)
if (ShapeY.color == UIColor.whiteColor()){
ShapeY.color = UIColor.blackColor()
}
else if (ShapeY.color == UIColor.blackColor()) {
ShapeY.color = UIColor.whiteColor()
}
}
}

I don't get how it would work so that each tap toggles it.
>>
File: 1449359689755.jpg (47KB, 613x695px) Image search: [Google]
1449359689755.jpg
47KB, 613x695px
>>55191416

>last minute change from phone call to video interview
>mfw I haven't shaved and my gf leaves her bong on my desk

FUCK
>>
>>55191416
Just practice your Fizzbuzzes and you should be fine.

Learn it in at least 10 different languages, one of which should be an Assembly
>>
>>55189062
lisp
>>
>>55189134
Post the actual asm
>>
>>55191756
>post the actual asm
Do you mean the machine code?
>>
>>55191663
Which assembly
>>
>>55191756
>compiles to
what more do you want?
>>
>>55191783
MIPS
>>
What does .PHONY do in makefiles?
>>
>>55191663
>Assembly
done
>>
>>55191903
https://stackoverflow.com/questions/2145590/what-is-the-purpose-of-phony-in-a-makefile#2145605

t. your friendly google proxy
>>
Is there a way of connecting to a database in javascript?

I'm trying to connect to a database on a webpage to store stuff and I'm using ASP.net and javascript for the page. I can't seem to work out how to connect to a database through ASP.net (all the tutorials are really complicated and don't really tell me anything).

I'm not concerned about any issues relating to connecting with javascript, I just want to know if it's possible and how to do it.
>>
>>55191958
Oh hey, another one.
https://stackoverflow.com/questions/857670/how-to-connect-to-sql-server-database-from-javascript-in-the-browser#857688

t. your friendly google proxy
>>
>>55191879
        .data
space: .asciiz " "
fizz: .asciiz "Fizz"
buzz: .asciiz "Buzz"
fizzbuzz: .asciiz "FizzBuzz"
i: .word 0
.text
main:
li $v0, 4
la $a0, space
syscall
lw $t0, i
beq $t0, 100, endl
add $t0, 1
sw $t0, i
li $t1, 15
div $t0, $t1
mfhi $t0
bne $t0, 0, next1
li $v0, 4
la $a0, fizzbuzz
syscall
j main
next1:
lw $t0, i
li $t1, 3
div $t0, $t1
mfhi $t0
bne $t0, 0, next2
li $v0, 4
la $a0, fizz
syscall
j main
next2:
lw $t0, i
li $t1, 5
div $t0, $t1
mfhi $t0
bne $t0, 0, next3
li $v0, 4
la $a0, buzz
syscall
j main
next3:
li $v0, 1
lw $a0, i
syscall
j main
endl:
li $v0, 10
syscall
>>
File: windows.jpg (16KB, 418x104px) Image search: [Google]
windows.jpg
16KB, 418x104px
> framework uses a custom language which you write in to a string

Why is this shit done? pisses me off to no end
>>
with Java... Every time I need to figure out a Java program, I end up being in almost physical pain. Huge trees of empty nested directories and files with nothing but method definitions that do nothing but return a property... or, better yet, tons of empty functions called pure virtual.

It's hard to feel the logic and necessity of code when you can't stop being flabbergasted why the language has to be so verbose and complicated.
>>
>>55189062
C
>>
>>55192423
What does C have to do with programming?
>>
>>55192447
Everything
>>
>>55192447
What's Linux
>>
>>55189134
>
bait_type

Is it _Bool or some shit?
>>
>>55192521
of course
>>
>>55192526
That's a smart optimisation then, nice.
>>
>>55189062
Graphs, diagrams, English text, and simple math

Programming isn't about languages.
>>
>>55192569
Where are you from again?
>>
>>55189062
python for prototyping
C# for quick software development aimed at Windows only
C++ for cross-platform software, or if I want to go to lower levels
lua for plugin development for the software I develop (they’re generally examples so users can create their own and share them)

As you might’ve guessed, I’m not that much into web dev (I find it boring as hell)
>>
>>55192607
>aimed at Windows only
Why? Mono is very good.
>>
>>55192607
You are a cancer.
>>
>>55189134
your function is a while true, it is "optimized" as an infinite loop...
>>
in R,
(function(x) (if (x == 1){print("HI")}else{print("GO AWAY")}))(1)
[1] "HI"
[1] "HI"

Why is it printing twice?
>>
>>55192631
I actually learnt C# with .NET only, so I have no idea how complete or not Mono is, and alas I have currently no time at all to learn another framework.

I might ask some time to my boss though, it would be interesting to be able to develop in C# for UNIX platforms
>>
>>55189062
Rust
>>
>>55192803
Mono implements .Net (with a few extensions and unimplemented stuff), you do not learn another framework as most C# code will probably run without the need to change it.
>>
>>55192755
what happens when you put the (1) in the next line
>>
File: 1419195559433.gif (1MB, 320x176px) Image search: [Google]
1419195559433.gif
1MB, 320x176px
>take interview with dev from small company
>no strict interview questions
>mostly just going over my work experience and what I designed and how I could improve on it
>did I know certain languages and what I could do with them

is it a red flag if a company doesn't ask shit like "write a BST and reverse it" during an interview? The company is pretty damn small and so far the people are likeable but I have heard that if a software company doesn't ask this that I should worry.

they actually showed me the code for their stuff it was pretty awesome.
>>
>>55192824
Oh I see, well I’ll take a look at what’s inside Mono. Thanks anon!
>>
>>55192860
>write a BST and reverse it
This is a meme.
>>
>>55192755
because of () instead of {} in function definition
>>
I want to add a single key/value pair to an array of objects. The data I'm working with might look like this:
var outerArray = [
{
akey: "cats",
innerArray: [
{stuff:1}, {stuff:2}, {stuff:3}
]
},
{
akey: "dogs",
innerArray: [
{stuff:4}, {stuff:5}, {stuff:6}
]
}
];

// what I want:
[
{stuff:1, akey: "cats"},
{stuff:2, akey: "cats"},
{stuff:3, akey: "cats"},
{stuff:4, akey: "dogs"},
{stuff:5, akey: "dogs"},
{stuff:6, akey: "dogs"}
]


Now, I know I can solve this really easily with some for loops:
var arr = [];
for (var obj of outerArray) {
for (var innerObj of obj.innerArray) {
innerObj.akey = obj.akey;

arr.push(innerObj);
}
// Or, instead of that push:
// arr = arr.concat(obj.innerArray)
}


But what I'd really like to do is solve this functionally. My best attempt was this:

students3.map(
student =>
student.grades.map(grades =>
({
id: grades.id,
score: grades.score,
name: student.name // Now we have their name in their grades.
})
)
)
// Get an array of just test score objects
.reduce((p, c) => p.concat(c), [])


I figure there's a better way to get my concatenated array of objects, each with their new key - maybe I should use 'zip' or 'zipWith'? I looked at RxJS and Ramda.JS but couldn't figure out a way to achieve this.

Thoughts?
>>
>>55192903
Why would you ever reverse a BST?
>>
File: 1403990045739.jpg (45KB, 643x439px) Image search: [Google]
1403990045739.jpg
45KB, 643x439px
>>55192990

it's meant to show if a coder knows recursion and pointers
>>
>>55193024
What if you reverse the tree without using recursion?
>>
>>55193037

the only other way to do it is looping which you can just convert to a recursive function.
>>
when some C lib return a char* and says it's utf-8 can i assume it to be NUL terminated?
>>
>>55193098
>the only other way is looping
>>
>>55192860

Interview questions are maximum meme, so it's really not a big deal.
>>
>>55192981
Here's my first re-attempt at a more functional way. Still, without some kind of zip, I feel like it could be improved.

outerArray = outerArray.reduce((previous, current) =>
previous.concat(
current.innerArray.map(x => (x.akey = current.akey, x))
), []);
>>
>>55193117
read the documentation
>>
>>55193240
>concat map
use bind
>>
Starting to learn about pipes in C, and can't quite get my head around how they work. How would I read a line from a text file using parent process and send it via pipe to child process so it prints it out?
>>
>>55193310
man pipe
>>
>>55193275
i wouldn't ask if it was so easy
>>
>>55193398
Read the source.
>>
>>55192846
doesn't let me evaluate it across multiple lines like that

>>55192959
ahhhhh, ok, thanks! that fixed it.
>>
>>55193288
Could you give me a hint on how to use bind?
I've never used bind before. And are you talking about Ramda.js's bind, or Javascript's bind?
>>
How do you specify that the main class in a jar's manifest is contained inside another jar in that jar? I don't want to make my multi-project and its dependencies into a fatjar.
>>
>>55193546
monadic bind

m >>= f = join (fmap f m)

join is concat
f is a -> m b
>>
>>55193583
java is so disgusting
>>
Whats the size of a bool. Is it the same as an int. stupid question I know but 1 and 0 are basically true and false. But it seems so inefficient to waste that much space. Especially if I have something like a bool array.
>>
>>55193773
In what language?
If it is in C, it could be of any size but it usually is 1 byte.
>>
>>55193603
I don't know haskell
this makes no sense to me
like 'a -> m b', that doesn't make sense
and
'm >>= (a -> mb) = concat(fmap (a -> m b) m)'

I mean what in tarnation does this mean?
>>
>>55193865
a -> m b
is the type signature
for a list
a -> [b]
a -> list<b>


>>= is an infix operator for bind
(>>=) m f
m is the monad object, f is the function to bind it with
>>
>>55193786
1 byte is more reasonable. I was thinking that it was the same size as an int. C++ btw.
>>
>>55193899
that's the type signature of f btw
>>
>>55193934
I do not know about C++, it's probably 1 byte as well, usually at least.
I do know that BOOL (or whatever it is called) in the winapi is an int.
>>
>mfw people give up on Haskell after 2 minutes because it isn't exactly the same as Java or Python
>mfw no face
>>
>>55193934
if you use C, you could use bitfields. So the space used for an int can contain 8 bool flags.
But memory isn't that much of a concern nowadays, excpet for embedded systems.
>>
File: 1450938190956.png (20KB, 300x300px) Image search: [Google]
1450938190956.png
20KB, 300x300px
>>55194007
>can't get address of bitfields
I understand why it is not allowed and that you could simply pass a pointer to the structure but it still annoys me.
>>
>>55193949
I've been trying to figure out how to use bind (currying) to solve this problem for over an hour now (since you first mentioned 'bind'), but haven't been able to make any progress.

The best I can do is replace the innards of 'reduce' with a curried function that basically does the same thing. It's more lines of code and I have to define a function too.

Maybe I'll get back to this later
>>
>>55194052
There is no (?prove me wrong!) common arch on which you can address a single bit
>>
>>55194109
bind =/= currying
you're using a language like C++ or something where bind means something different
>>
>>55194137
You can do something similar with some 86 asm magic actually, but even then, it is not a single bit. It actually allocates whole bytes (multiple bytes in fact to fulfil alignment)
>>
>>55194142
in Haskell and ML derivatives and most FP languages, currying is implicit

f x y is the same as (f x) y is the same as
let g = f x
g y

and
let f = \x -> \y -> x + y
is the same as
f x y = x + y


but all of that is besides the point, what language are you using?
it might be called something like flatMap
>>
>>55194142
oh.. so this past hour or so, while ive CLEARLY been trying to solve this problem in JAVASCRIPT, you said 'use bind' without specifying "but not javascript's bind".

So Ive spent an hour trying to do something that wasn't going to work from the getgo. Because miscommunication. Thanks buddy
>>
>>55194158
function cm(a, b, c){
return a + b + c;
}

var curried1 = cm.bind(null, 1);

console.log(curried1(2, 3));

var curried2 = curried1.bind(null, 2);

console.log(curried2(3));

var curried3 = curried2.bind(null, 3);

console.log(curried3());

I don't see the difference
>>
>>55194187

Javascript isn't even functional
>>
>>55194187
>you said 'use bind' without specifying "but not javascript's bind".
He said monadic bind you jerk.
>>
>lambdas + map + reduce + zip
>g-guys am i functional?
no
>>
Is this the correct way to compute a TCP/UDP checksum, or am I missing something?

uint16_t checksum(const std::vector<uint16_t>& segment)
{
uint16_t res = 0x0000;

for(auto word : segment)
{
uint32_t sum = res + word;
uint16_t *high, *low;

high = reinterpret_cast<uint16_t*>(&sum) + 1 ;
low = reinterpret_cast<uint16_t*>(&sum);

bool overflow = *(high) != 0;
assert(overflow == (*low != sum));

if(overflow)
*low += *high;

res = *low;
}

return ~res;
}


>inb4 use bitshifts instead
>>
>>55194269

Nobody would suggest those things make a language functional. We only took the good parts of functional programming and left the rest of the garbage behind. :)
>>
>>55194351
if that's all you wanted use comprehensions instead
>>
>>55194351
Good morning race mixing cuckold, how is your wife's black boyfriend doing?
>>
>>55194254
i just assumed monadic bind was the same as bind
>>
>>55194497

Good, thanks for asking.
>>
>>55194269
how is it not functional?
My code doesn't mutate data
>>
>>55194315
>am I missing something
no, actually you added something useless : the ++part
>>
File: le leafy faec.jpg (61KB, 600x842px) Image search: [Google]
le leafy faec.jpg
61KB, 600x842px
>>55194207
>>
>>55194007
>So the space used for an int can contain 8 bool flags
it can contain at least 16 bools
>>
>>55194841
sorry, meant char obviously
>>
File: nVjQ1iE.png (2MB, 1357x1281px) Image search: [Google]
nVjQ1iE.png
2MB, 1357x1281px
What did she mean by this?
>>
>>55190797
A port is just a number identifying a service.
A client will initiate a connection on a designated port; the server will "listen" for a specific type of connection on that port.

Basically, if you're using SSL, a server will wait for things such as host validation and key exchange.
If you're using IRC the server will wait for PASS, NICK, HOST etc.
If you're using http the server will wait for an http header.

Each type of service has specific parameters which are required to illicit a response from the server.
A service is then defined by what kind of data gets transmitted, and also how it gets transmitted.
Port numbers serve to uniquely identify various services at the network level, making it system independent.

There are internal ports and external ports.
>>
>>55190929
The simple fact that it is the shortest C book gives it eternal value in my humble opinion.
>>
Can someone help me with some programming in C? I must create a program that takes a string from the user (lowercase) and transforms it in uppercase but the program must stop if an uppercase is inserted. Any help would be appreciated
>>
>>55190929
>outdated programming techniques
Most of them are great.

>examples which are barely helpful, and often don't run on new PCs.
Both of these are bs.
>>
File: Philosophie-final-state-1907.jpg (411KB, 1335x1957px) Image search: [Google]
Philosophie-final-state-1907.jpg
411KB, 1335x1957px
Is this the right way to do error handling in OpenSSL?

int ssl_shutdown(SSL *ssl_connection)
{
int rv, err;
ERR_clear_error();
rv = SSL_shutdown(ssl_connection);

if (rv == 0)
SSL_shutdown(ssl_connection);

if (rv < 0)
{
err = SSL_get_error(ssl_connection, rv);

if (err == SSL_ERROR_SSL)
fprintf(stderr, "%s\n", ERR_error_string(ERR_get_error(), NULL));

fprintf(stderr, "%s\n", SSL_state_string(ssl_connection));

return 1;
}

SSL_free(ssl_connection);
return 0;
}


The docs are really confusing.
What is the difference between
SSL_get_error
and
ERR_get_error
?
>>
>>55195497
Use libressl instead
>>
>>55195292
You can use a bitshift to convert a lowercase character to an uppercase character, that's all the help I'll give.
>>
>>55195509
I thought about it, but I refuse to use a library developed by fat autistic ponyfags.
>>
>>55195568
>use a bitshift
you're an idiot, stop giving bad advice
>>
>>55195292
Just use
if((val>=''a")&(val<=z))
{
val-=20;
}
>>
>>55195615
Fuck, sorry I've had a drink.
if((val>='a')&(val<='z'))
{
val-=20;
}
>>
>>55195642
But the program must stop taking chars if an uppercase is entered
>>
>>55195615
>>55195642
Not portable C.
>>
C/C++: What are the different ways to pass a parameter into a function?

Trick question? I was aware there was only one?


void printSomething(int x)
{
cout << x;
}


That's the only way is it not? Including it within the parenthesis of the function?
>>
>>55195670
You can't take it from there? Just stick it in a
while(!((val>='A')&(val<='Z'))&!(val>sizeof(val)/sizeof(type)))
{
}

Or some shit.
>>
>>55195712
What's the difference?
>>
>>55195740
See >>55195712
>>
>>55195712
lol
>>
>>55195765
Between?
>>
>>55195712
EBCDIC can go take a hike anyway
>>
File: 1234567890.jpg (26KB, 640x480px) Image search: [Google]
1234567890.jpg
26KB, 640x480px
>>55195784
Are you messing with me because I said I'd had a drink?
>>
File: 1458471102345.jpg (51KB, 907x718px) Image search: [Google]
1458471102345.jpg
51KB, 907x718px
>>55195772
lol what?

>>55195823
>had a drink
normalfag
>>
>>55195568
>>55195615
>>55195642
>>55195765
>>55195772
>>55195784
>>55195797
>>55195823
toupper, you fucking idiots
>>
>>55195898
If you are indeed using punch card values like a caveman, there is still a range of values and thus that code should still work with a little tweaking.
>>
>>55195925
Doesn't help with portability?
>>
>>55195723
Can someone answer this please?
>>
>>55195947
Just use isalpha like a normal person
>>
>>55195723
>>55195952
Doesn't it mean pass by value or pass by reference?
>>
>>55195981
>Using redundant features
>>
>>55196005
>portability is redundant
>>
>>55195723
>>55195952
Go away autist, holy shit
>>
>>55196049
Who exactly am I catering to by not factoring in alternatives to UTF-8?
>>
Updated my script to download images from 4chan threads, because apparently 4chan requires me to spoof my user agent now.

>Use the JSON API

No.

#!/usr/bin/env python3

import argparse, bs4, os, requests

parser = argparse.ArgumentParser()
parser.add_argument("url", help="Link to thread")
parser.add_argument("-d", help="Directory to download to")
args = parser.parse_args()

if args.d:
if not os.path.exists(args.d):
os.makedirs(args.d)
os.chdir(args.d)

spoof = {"user-agent" : "Mozilla/5.0 (X11; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0"}

html = requests.get(args.url, headers=spoof).text
soup = bs4.BeautifulSoup(html, "html.parser")

for fileinfo in soup.find_all("a", class_="fileThumb"):

image_link = "https:" + fileinfo.get("href")
image_filename = image_link.rsplit("/", 1)[1]

if not os.path.exists(image_filename):
image_data = requests.get(image_link, headers=spoof)
image_file = open(image_filename, "wb")
image_file.write(image_data.content)
image_file.close()
>>
trying to reference a picture relatively, but the application can not find it. I need to specific an absolute path in order for it to load.

I'm using SFML if it matters in Visual Studio 2015 - any ideas on how I can reference this without the absolute path?
>>
File: 1465948906771.png (21KB, 357x313px) Image search: [Google]
1465948906771.png
21KB, 357x313px
>tfw you will never be good
Everything I've done has already been done better by somebody else.

What is the point?
>>
>>55196502
Don't try to be the best. You will never be the best no matter what you do. Even the best of the best are really just tied with equally best people.

Just do something interesting and people will notice. It doesn't have to be innovative or impressive at all.
>>
C is not that hard to be honest family.

void *(*(*f[])(void))(int *x, int *y)

f is an array of unspecified size of pointers to functions that take no arguments that return pointers to functions that take two pointers to integers as arguments and return pointers to void.
>>
>>55196906
You need to cast it a few more times.
>>
File: 1466179919778.png (125KB, 813x600px) Image search: [Google]
1466179919778.png
125KB, 813x600px
>>
>>55196906
Or in Algol 68 style, which happens to be in the same order as the English description.
[] ptr proc ptr proc (ptr int, ptr int) ptr void
>>
File: 1464027954258.png (299KB, 480x480px) Image search: [Google]
1464027954258.png
299KB, 480x480px
What's a good language that is object oriented? I originally just used C, but I find more and more I need classes.

C++ feels too bloated, is there something _almost_ as elegant as C but also with classes and objects?
>>
>>55197034
Yes, it is called C++.
>>
For swift in xcode

Why does this change the blend factor after the first touch and then doesn't? How do I make it hear every touch?

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
/* Called when a touch begins */

Mainball.colorBlendFactor *= -1.0

}
>>
>>55197034
Rust
>>
>>55190929
K&R is god tier
>>
>>55197086
I've been stuck on this all day and would really appreciate any help. I'm brand new to swift.
>>
>>55196906
doesn't f[] *need* a size to compile?
>>
File: 1466449301588.jpg (55KB, 499x499px) Image search: [Google]
1466449301588.jpg
55KB, 499x499px
What's the best way to read about basic CS concepts like O-time?
I've been self-teaching myself programming for years and I know a lot of higher-level stuff, but I still have large gaps in my knowledge when it comes to the basics of computer science itself and I want to fill those gaps.
>>
>>55197086
>>55197222
Is it possible that colorBlendFactor is clamped to some range? Maybe it isn't allowed to be less than 0, so negative values get clamped to 0. Then any future touch events won't change it.
Add debug code to check whether the touch event is being triggered, and what the value of colorBlendFactor is at the end.
>>
>>55190173
more_like_poop.jpg
>>
>>55197448
you could pick a concept like O notation then google o notation pdf college slides or watch online lectures. You could even try to find a lecture with a curriculum posted online and follow it along to see what you can learn. I have found big long courses with slides and video lectures that's a lot like college.
>>
What language do I actually learn? Did some java back in the day in high school but i don't remember shit but a few concepts of CS but that's about it. /g/ fucking sucks at coming to terms with a language that everyone should know...so what do?
>>
>>55197498
I got the same results when I had an if statement that check the colour and then changed it and when I made a variable to be the blend factor and got it to change and when I just had a function call in the touchBegan it only called once. I have tried many things and can only get it to listen to one touch of the screen.
>>
>>55197448
you could pick a concept like O notation then google o notation pdf college slides or watch online lectures. You could even try to find a lecture with a curriculum posted online and follow it along to see what you can learn. I have found big long courses with slides and video lectures that's a lot like college.
>>
>>55197711
>>>/sqt/
>>
I have started to learn to code in Swift (first language) this week.

Today I am learning about Bools. Only Sir Lancelot can enter, and only if he is level 3 or above.

//set Name to Sir Lancelot
let Name:String = "Sir Lancelot"

//bool for name
let NameCheck:Bool = Name == "Sir Lancelot"


//Set level to 3
let Level:Int = 3

//bool for level
let LevelCheck = Level >= 3


let AllowedIn:Bool = LevelCheck && NameCheck
>>
>>55197711

You don't use bullshit excuses like "I don't know what language to pick". That is just a way for you to postpone and procrastinate actually doing something. Java is fine, C# is fine. Think of something you want to write and just pick a language to do it with. If you are a noob start with something high level, C# is my suggestion. Now go do shit.
>>
>>55197711
I've been learning for a week and have picked Swift because I want to make an iPhone app, so it's practical.

Just pick one that makes sense for you based on what you can see yourself actually using it for and go.
>>
>>55197295
It'll allow you to declare an array of unspecified size, but you might overwrite data if you try to write to it.
>>
>>55197711
Python, go to coursera and do "Introduction to Computer Science"

Also try Codeacademy.com's python course while you're doing that so you can learn by programming yourself.
>>
>>55191435
At least do it correctly

∀x (vim_user(x) ⇒ ¬intelligent(x))
where vim_user(x) is true iff x is a vim user
and intelligent(x) is true iff x is intelligent
>>
>>55197745
>comparing strings with ==
>>
File: 1465657921291.jpg (57KB, 440x630px) Image search: [Google]
1465657921291.jpg
57KB, 440x630px
int date_compare(date a, date b) {
if(a.year < b.year) {
return -1;
}
if(a.year > b.year) {
return 1;
}
if(a.month < b.month) {
return -1;
}
if(a.month > b.month) {
return 1;
}
if(a.day < b.day) {
return -1;
}
if(a.day > b.day) {
return 1;
}
return 0;
}


pls rate
>>
>>55190003

i found it on google in 2 secs.
>>
I don't know if that one anon is here who was asking about Cython yesterday, but I'm working on writing the code in Cython, compiling it and then using it in a C program. I'm close, but it keeps handing me a segfault, so I'm not sure where I'm going wrong here.
>>
>>55197954
int date_compare(date a, date b) {
if ((a.year < b.year) ||
(a.month < b.month) ||
(a.day < b.day)) {
return -1;
}
if((a.year > b.year) ||
(a.month > b.month) ||
(a.day > b.day)){
return 1;
}
return 0;
}
>>
>>55197954

Prof told us not to use multiple return statements. It might be best to store the result in a variable instead and return that.

http://programmers.stackexchange.com/questions/118703/where-did-the-notion-of-one-return-only-come-from



>>
>>55197987
post the code already
>>
>>55197954

if (a.year > b.year ? 1 : -1 && a.month > b.month ? 1: -1 && a.day > b.day ? 1:-1) {
result = 1;
}
else {
result = -1;
}
>>
File: 1462389056172.jpg (61KB, 540x540px) Image search: [Google]
1462389056172.jpg
61KB, 540x540px
>>55188975
In ruby, I'm trying to prevent users from adding someone as a friend if either one of them has the other on their ignore list. Depending on who's ignoring whom, users can be "passive_foes", "active_foes", or either one, which is defined as just "foes". All 3 of those are defined under user.rb and seem to work as intended.

In the friendships controller, I'm trying to define

class FriendshipsController < ApplicationController
before_action :ignored_user, only: :create


And

  def ignored_user
if current_user.foes.include?(@user)
flash[:notice] = "Unable to send friend request."
redirect_to :back
end
end


All of that seems to work except the "if current_user blah blah" line. If I replace it with "if current_user.admin?" then it works exactly as you'd expect. If that user is an admin, they can't send anyone friend requests. If I replace it with "if current_user.id == 2", it also works as you'd expect. Anyone other than user #2 can freely send friend requests, but user #2 can't send friend requests and that error message shows up as intended. I've tried replacing the faulty line with many variations of the above code, including things like
if Disagreement.where(foe_id: [@user, params[:id]], user_id: [current_user, params[:id]]).first
(which works elsewhere, confirmed, just not here).

Do you know what I'm doing wrong? Because I sure don't. Any help would be greatly appreciated.
>>
>>55198015
That's not equivalent.
2016-06-22 will be "before" 2015-07-22.
>>
>>55198027
There is no harm in using multiple return statements, especially when there is no malloc involved.
>>
>>55198015
>>55197954

This is retarded. Consider the dates 2016-10-11 and 2016-8-9. By this function, it would return 0 when they are not the same date.
>>
>>55198109
i dont care senpai lmao
>>
>>55198094
I'll post it in the next thread, and mess around with it in the meantime
>>
>>55197830
What should I use?
>>
NEW THREAD!!

>>55198250
>>
>>55198254
Thank you hime.
>>
>>55189890
Retard.
#define is a preprocessor directive, it works on tokens.
The preprocessor doesn't know what the fuck an "identifier" is.

Do not claim proficiency in a language you do not know, now kill yourself.
>>
>>55198254
thnx trapfriend
>>
best free books/tutorials to read for a complete beginner to learn Java? Besides learn Java the hard way. I honestly don't have the $30 for the book.
Thread posts: 312
Thread images: 31


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