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

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

Thread replies: 255
Thread images: 31
File: 09-16-26-Hackers-With-An-Agenda.jpg (809 KB, 1000x749) Image search: [Google]
09-16-26-Hackers-With-An-Agenda.jpg
809 KB, 1000x749
/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 (1 MB, 1000x1400) Image search: [Google]
himegoto considered harmful.png
1 MB, 1000x1400
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 (5 KB, 270x175) Image search: [Google]
1464823306282.png
5 KB, 270x175
>>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 (161 KB, 870x722) Image search: [Google]
plz_gibe_strong_ai.jpg
161 KB, 870x722
>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 (29 KB, 337x404) Image search: [Google]
smug_sakura.jpg
29 KB, 337x404
>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 (188 KB, 1680x910) Image search: [Google]
1463612034039.jpg
188 KB, 1680x910
>>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 (1021 KB, 870x717) Image search: [Google]
1453656893900.png
1021 KB, 870x717
>>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 (15 KB, 300x100) Image search: [Google]
33.jpg
15 KB, 300x100
>>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 (107 KB, 1163x674) Image search: [Google]
popularity of oop explained.png
107 KB, 1163x674
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 (1 MB, 480x270) Image search: [Google]
1466355216727.gif
1 MB, 480x270
>>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 (2 KB, 512x86) Image search: [Google]
averaging 2 integers.png
2 KB, 512x86
>>55190339
done
>>
Are linked lists better than arrays?
>>
File: Python_logo_and_wordmark.svg.png (7 KB, 260x77) Image search: [Google]
Python_logo_and_wordmark.svg.png
7 KB, 260x77
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 (107 KB, 792x1023) Image search: [Google]
Kandr.png
107 KB, 792x1023
>>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 (3 MB, 658x800) Image search: [Google]
1442284683769.gif
3 MB, 658x800
>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 (47 KB, 613x695) Image search: [Google]
1449359689755.jpg
47 KB, 613x695
>>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 (16 KB, 418x104) Image search: [Google]
windows.jpg
16 KB, 418x104
> 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 (1 MB, 320x176) Image search: [Google]
1419195559433.gif
1 MB, 320x176
>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 (45 KB, 643x439) Image search: [Google]
1403990045739.jpg
45 KB, 643x439
>>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 (20 KB, 300x300) Image search: [Google]
1450938190956.png
20 KB, 300x300
>>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 (61 KB, 600x842) Image search: [Google]
le leafy faec.jpg
61 KB, 600x842
>>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 (2 MB, 1357x1281) Image search: [Google]
nVjQ1iE.png
2 MB, 1357x1281
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 (411 KB, 1335x1957) Image search: [Google]
Philosophie-final-state-1907.jpg
411 KB, 1335x1957
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 (26 KB, 640x480) Image search: [Google]
1234567890.jpg
26 KB, 640x480
>>55195784
Are you messing with me because I said I'd had a drink?
>>
File: 1458471102345.jpg (51 KB, 907x718) Image search: [Google]
1458471102345.jpg
51 KB, 907x718
>>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?
Thread replies: 255
Thread images: 31

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.