[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: 332
Thread images: 35

File: dpt-a.jpg (194KB, 1600x1200px) Image search: [Google]
dpt-a.jpg
194KB, 1600x1200px
Old thread - >>57689596

What are you working on, /g/?
>>
I'm going to be starting a computer science degree halfway through 2017. That means I have 7-8 months to put into self-study before then. What would be the best way to spend that time?
>>
>>57696660
Install gentoo
>>
>mfw we're back to fag OP pic
>>
>>57696666
Waste of good quads.
>>
>>57696673
>{{current year}}
>not liking anime
>>
pedo thread, sage
>>
I'm working on a turing virtual machine. Based on the machines turing described in his paper "on computable numbers". iterates along memory and place 0s or 1s in memory. There's a bunch of other details that will require some hammering out
>>
>>57696619
Anime is trash
>>
>>57696660
What do you know right now? Anything you might consider relevant to CS.
Also things like what kind of thinker you are. What do you find easy what do you have problems with?
In physics exams did you manage the practical experiments well with figuring out how to measure what you were meant to measure?
What is your end goal with this degree?
Do you consider the discrete maths aspect of CS particularly interesting or are you interested in writing programs that do interesting stuff?
What motivates you, the results or the process?

And no lying. You're anonymous.
>>
Downvoted because anime
>>
WHY ARE THERE TWO THREADS?!
>>57696721
>>
>>57696776
This one was posted early. >>57696721 is the real thread.
>>
>>57696778
Fucking newfags
>>
>>57696776
this is the real one
>>
>>57696660
Try to get a feel of all the different areas of Computer Science. Do a bit of a research, CS is a really vast field.
Pick up something that you find interesting and which is beginner friendly (i.e. many good tutorials available).
>>
>>57696817
>>57696811
I DONT KNOW WHAT TO BELIEVE ANYMORE
>>
File: 1475580940102.png (20KB, 506x606px) Image search: [Google]
1475580940102.png
20KB, 506x606px
>tfw to intelligent to start a thread war over pixels
>>
hello this is my website http://andreruffert.com/
>>
>>57696840
>to intelligent
>>
>>57696838
>>57696850
Believe me
>>
File: S-1228080-www.kaifineart.com-4.jpg (189KB, 650x919px) Image search: [Google]
S-1228080-www.kaifineart.com-4.jpg
189KB, 650x919px
>>57696838
Simple rule, if it doesn't have an anime image in OP, it's not the real /dpt/ thread
>>
>>57696879
Anon please don't play with my feelings like that.
>>
>>57696845
>Thanks for taking a look :) It's always nice to see you. Have a nice day!

:^)
Nice page tho, very simple and to the point.
>>
File: doyouevenlambda.png (29KB, 811x805px) Image search: [Google]
doyouevenlambda.png
29KB, 811x805px
>>57696660
http://htdp.org/
https://www.edx.org/xseries/systematic-program-design-0

or

http://www.cs.hmc.edu/csforall/
https://www.edx.org/course/cs-all-introduction-computer-science-harveymuddx-cs005x

and you will probably be ready to lecture you future cs101 teacher.
>>
>>57696845
Why do you have an instagram link but no github?
>>
>>57696915
>>57696958
I was kidding...

FOOLS
>>
I wish I were a wheelchair bound grill
>>
Ok come try my webshit:
http://korbo.ga/fqtTx
>>
I'm going to nuke this thread boys because it's a mess having two threads.

other thread is here:
>>57696721
>>57696721
>>57696721
>>57696721
>>57696721
>>
File: OP.png (3KB, 698x1284px) Image search: [Google]
OP.png
3KB, 698x1284px
>>57696966
>>
>>57696987
That's not the point.
>>
>>57696987
>damage control :^) :^) :^)
>>
>>57696984
Sorry man. I had to kill the thread. For the greater good.
>>
I will just let this here:
--source: Haskell Data Analysis Cookbook
import Text.CSV

-- Parses a CSV file
main :: IO ()
main = do
let fileName = "input.csv"
input <- readFile fileName
let csv = parseCSV fileName input
either handleError doWork csv

handleError csv = putStrLn "not a CSV"
doWork csv = (print.findOldest.tail) (filter (\x -> length x == 2) csv)

-- Finds oldest person.
findOldest :: [Record] -> Record
findOldest [] = []
findOldest items = foldl1 (\a x -> if age x > age a then x else a) items

age [a,b] = toInt b

toInt :: String -> Int
toInt = read

import pandas as pd 
table = pd.read_csv("input.csv")
print(table[table.age==max(table.age)])
>>
>>57696984
But that thread is kill
>>
Behind anime posters there's always a hasklel fag
>>
>>57696998
np. thank you based mod for making anime on /g/ great again.
>>
>>57696998
Ok. well thanks for being so mature.
Almost managed to get in the last copy.
>>
>>57696619
I'm working on a 4chan browser for the terminal. Basically allowing you to browse 4chan from your terminal. Using NodeJs, might rewrite it in Golang.
>>
>>57697010
yw. I'm not a mod though. I just made the other thread.
>>
>>57697012
like lynx?
>>
oh well, they nuked the better thread, so I will make my question here again: if I have a job as computer scientist (4 years of experience), will SICP give me an edge if I haven't still read it?
>>
>Computer Scientists called for vote recount in a state where there are no digital voting machines.

>CS fags will defend this
>>
>>57697041
What the fuck would a computer scientist know about voting anyways? That's some retarded shit.
>>
>>57697041
Can Hillary even win with all the states they want a recount in? If there's a draw wouldn't trump still win the congress election?
>>
>>57697041
People appropriating sciences to make their political point heard is nothing new.

It's like a biologist talking about creationism.
Means absolutely nothing.
>>
>>57696756
4th year cs here.

Only interested in creating cool shit.
I have fucked up.
>>
>>57697065
>It's like a biologist talking about creationism.
Sorta does help discredit creationism though.
>>
MOD IS A FUCKING WEABOO FAG
>>
>>57697065
>It's like a biologist talking about creationism.
>not like they know a thing or two about evolution an such
>>
>>57697080
Yeah correct assessment I'd say.
>>57697085
Yeah but it's more about the alternative view being explained. Not about how creationism works/doesn't work from the inside view.
Probably a pretty poor example. Astronomers vs particle physicists might be something.
>>57697097
There's no mod, at least no reason to believe there is one.
>>
why is memset in string.h?
>>
>>57696940
Is it worthwhile to do both courses?
>>
is sicp a good book as an intro to functional programming? or are there better ones out?
>>
File: 1427325174842.png (98KB, 430x180px) Image search: [Google]
1427325174842.png
98KB, 430x180px
post a screen shot of the last code you wrote
>>
>>57697023
>lynx
Yeah, i took inspiration from Lynx.
>>
>>57697097
That's sad.
>>
>>57697114
Dumb confusing reasons.
>>
>>57697114
Because you need that only for strings.
>>
>>57697114
Because actually string.h is defined as a standard header that declares functions that treat array of characters and not only strings. Functions like memcpy and memset take arguments that are treated as pointers to the first element of an object of type array of characters.

>(C99, 7.21.1p1) The header < string.h > declares one type and several functions, and defines one macro useful for manipulating arrays of character type and other objects treated as arrays of character type.
>>
>>57697110
>Not about how creationism works/doesn't work from the inside view.
Sure, but most creationists will strongly hold the opinion that creationism must be true because biology and evolution doesn't make sense. Most religious people have a lot of logical reasoning behind to back up their "faith".

>There's no mod, at least no reason to believe there is one.
Just because we can't prove the existence of Mod 100% doesn't mean he can't be real.
>>
>>57697158
>literal copy from stackoverflow
Good. Just tell him to google it though.
>>
>>57696999
I wanted to say how much haskell was a disaster, but you're WRONG. It's a very bad example. It's a total disaster.
>>
>>57697177
i wrote that response in stackoverflow, though
>>
File: carmack_sicp.png (54KB, 618x314px) Image search: [Google]
carmack_sicp.png
54KB, 618x314px
>>57697039
do you know what's procedural abstraction and how to use it?
do you know what's data abstraction and how to use it?
do you know how to separate data from logic efficiently?
do you know how to arrange you code to maximize readability?
do you know what's the difference between a function and a procedure?
do you know what's the difference between interpretation and compilation?
have you wrote a metacircular evaluator?

https://people.eecs.berkeley.edu/~bh/sicp.html
>>
File: Screenshot_2016-11-26_15-46-34.png (99KB, 989x708px) Image search: [Google]
Screenshot_2016-11-26_15-46-34.png
99KB, 989x708px
>>57697138
>>
>>57697232
Is that MIPS assembly?
>>
>>57696619
"The top five tech companies Apple, Microsoft, Alphabet, Cisco and Oracle [..]"

Why are Cisco and Oracle big lol? Besides using MySQL a few times which I believe is made (or bought) by Oracle, I don't think I ever use or hear anything about those companies? I guess there were some idiots in my class in highschool who needed Cisco certs for their pleb syswork career, but I always thought about these companies as some irrelevant shit that will inevitably die

Why are they still around?
>>
>>57697138
God I hate that face. I don't know why, it doesn't seem particularly offensive on the surface but I want to punch it so so bad. It doesn't compare to any face I've seen in at least a year.
Where did you find this?
Is this from an anti-bully campaign? Am I just a natural bully?

They sure know how to keep their budget if it was.
>>
>>57696619

Picked up SICP today from my college library along with the C Programming Language because /g/ memes.

>Open SICP
>The entire thing is in Lisp
>Read how to define a function
>lul wtf is this

Did people ever actually think Lisp was good? I can see why Dijkstra thought it was abhorrent.

Does it get any more readable/better than this or should I just move onto the C programming language?

I actually want to learn more about lambda calculus and see what practical application of formal methods so, should I stick with it or is the entire book just predicate calculus laws in programming format?
>>
>>57697262
>>Read how to define a function
did you get past the second chapter?
>>
>>57697260
>Where did you find this?
dunno. had this picture saved in my pc for months, or years
>>
>>57697262
>I can see why Dijkstra thought it was abhorrent.
nice try but if you really had read dijkstra, you would have know that he actually loved lisp.
>>
>>57697257
Oracle
>java
>mysql
>sparc
>solaris
>some other shit

Cisco
>literally everything network related
>>
>>57697218
I think it will help me somewhat then.
>>
>>57697248
No, it's for an in house risc processor at my uni, pretty simple stuff. It's for the digital systems design class
>>
File: last.jpg (171KB, 518x1022px) Image search: [Google]
last.jpg
171KB, 518x1022px
>>57697138
Does copy pasting a giant struct I don't want to write on my own count?
>>
>>57697257
>microsoft and apple
>not irrelevant shit that will die
>>
>>57697257
>how is Cisco big
your post probably went through 10 Cisco routers to be posted
>>
>>57697347
absolutely.

what are those bit fields for?
>>
>>57697262
I just opened that MIT site too.
>Lisp
Fuck this. Can i translate from lisp to F#?
>>
>>57697262
http://composingprograms.com/
>>
>>57697273

Sorry a procedure, and no I'm only on page 18. So far though it's reading like a LISP manual
>>
>>57697324
>>java
Hopefully will get replaced by anything even C#
>>mysql
Currently being replaced by Postgresql or NoSQL
>>sparc
Don't even know what it is
>>solaris
Gonna get replaced by Elasticsearch

So I wasn't totally wrong
>>
>>57697387
>So far though it's reading like a LISP manual
wtf, sicp is not even using lisp but scheme and it's barely about the language.
>>
>>57697370
mapping, it's the ATA device identity structure, I read the info from the device into an array, and then just cast that fucker to the struct, may or may not be undefined behavior, but it works.
>>
>>57697138
>>
>>57696666
this.
>>
>>57697406
He's retarded, ignore him
>>
i want to remove two style rules on a website using greasemonkey, but apparently i'm too retarded to get it to work.

#mainContainerFrontPage {
background: #ededed url("../images/mainbg.png") repeat-y;
}


.barRight {
padding-left: 475px;
}
>>
I posted it in the good /dpt/ thread but the mode is an anime weeabo.

type concat_string =
| String of string
| List of concat_string list
;;

let string s = String s;;

let list l = List l;;

let rec print_structure ppf = function
| String s -> Format.fprintf ppf "%S" s
| List l ->
let body ppf = function
| [] -> ()
| [x] -> print_structure ppf x
| x :: xs ->
Format.fprintf
ppf "%a%a"
print_structure x
(fun ppf ->
List.iter (Format.fprintf ppf "@ %a" print_structure))
xs in
Format.fprintf ppf "@[<hv 2>(@,%a@;<0 -2>)@]" body l
;;

let rec print ppf = function
| String s -> Format.fprintf ppf "%s" s
| List l -> List.iter (print ppf) l
;;

let letters = "abcdefghijklmnopqrstuvwxyz";;

let random_string () =
String.init 10 (fun _ -> letters.[Random.int 26])
;;

let list_init l f =
let rec loop accu = function
| -1 -> accu
| i -> loop (f i :: accu) (pred i) in
loop [] (pred l)
;;

let rec mk_tree = function
| 0 -> string (random_string ())
| k -> list (list_init (Random.int 3) (fun _ -> mk_tree (pred k)))
;;

let main () =
Random.self_init ();
Format.printf "@[%a@]@." print_structure (mk_tree (Random.int 10))
;;

let () = main ();;
>>
>>57697391
Why does java need to get replaced? I doubt it will ever get replaced by c# more likely another jvm language.

Oracle also offers a commercial nosql solution :^)
>>
>>57697406
scheme is lisp.... there's more lisps than common lisp....
>>
>>57697472
why is the top type called cancat_string? would string_tree not make more sense?
>>
>>57697406

It's just eye cancer as far as readability goes unless you're full autist, which i guess is why /g/ loves it
>>
>>57697257
I die everytime some indian dude in IT tries to give me advice by telling me to get certifications since I'm in CS
>>
>>57697492
It's because it's a type that allow O(1) concatenation. There are missing functions, but the underlying structure wouldn't be in the corresponding ".mli" file.
>>
>>57697516
still sounds like a bad name. What it is is a tree type. Makes it harder to read imo. Something called string_concat should be a function for concating strings.
>>
File: parphobia.png (116KB, 629x588px) Image search: [Google]
parphobia.png
116KB, 629x588px
>>57697488
http://wiki.c2.com/?IsSchemeLisp

>>57697501
i find the readability of s-expressions great.
>>
>>57697545
Did you read the "*.mli" explaining everything? Because the goal of that code is written in the interface file.
>>
>>57697262
>>57697372
The stupidity of C-niggers and ML-niggers never ceases to amaze.

I'm sorry you are struggling with a textbook for computer science freshmen.
But by all means blame it on the parentheses!
>>
I'd like to see C-niggers or ML-niggers rewrite the metacircular evaluator section in their own computer ebonics dialect
>>
>>57697546
>http://wiki.c2.com/?IsSchemeLisp
really makes me think... are clojure or joxa lisp...
>>
>>57697626
how is that metahomosexual homosexualizator section used in my big data job?
>>
>>57697262
LISP was originally supposed to use m-expressions (a syntax more similar to ML) but the dumb niggers could never get it to work correctly
https://en.wikipedia.org/wiki/M-expression
>>
"is X lisp?"

>When he finished Peter [Norvig] took questions and to my surprise called first on the rumpled old guy who had wandered in just before the talk began and eased himself into a chair just across the aisle from me and a few rows up.

>This guy had wild white hair and a scraggly white beard and looked hopelessly lost as if he had gotten separated from the tour group and wandered in mostly to rest his feet and just a little to see what we were all up to. My first thought was that he would be terribly disappointed by our bizarre topic and my second thought was that he would be about the right age, Stanford is just down the road, I think he is still at Stanford -- could it be?

>"Yes, John?" Peter said.

>I won't pretend to remember Lisp inventor John McCarthy's exact words which is odd because there were only about ten but he simply asked if Python could gracefully manipulate Python code as data.

>"No, John, it can't," said Peter and nothing more, graciously assenting to the professor's critique, and McCarthy said no more though Peter waited a moment to see if he would and in the silence a thousand words were said.
>>
>>57697673
i often see DSL being used in big data
>>
>>57697673
Why are you seeking answers in a computer science textbook if you already have a ENTERPRISE-tier job that just requires you to jockey libraries all day?
>>
>>57697701
but python does
>>
>>57697757
no.
>>
>>57697757
"gracefully" is the key word there

Do python functions turn into lists with the flick of a quote?
>>
Is the land of Lisp a fun and easy way to start for beginners ?
>>
>>57697810
Yes, it's great.

I personally think Common Lisp has too much cruft and prefer Scheme, but the book itself is top-notch.
>>
>>57697546
holy shit lisp really is that much gay ass ugly I thought /g/ was just joking
>>
>>57697600
I don't give a fuck about shitty lisp. i will read it using a F# translation because I'm not from a god forsaken era. :^)
>>
>>57697787
python has eval, exec, reflection, runtime ast, ...
>>
>>57697546
so what you see is just arbitrarily placed words?
sort of like python except without a colon
>>
>>57697831
The S-expression is the anchoring feature of the language, which makes it able to do things that myopic monad-diddlers and imperative monkeys can only dream of. I'm sorry you're too much of a baby duck to wrap your head around the concept.
>>
OCaml, F# a shit
Haskell ok
Idris better
>>
>>57697841
Enjoy your blub, ML-nigger
>>
if computer scientists are so smart why don't they have good jobs?
>>
>>57697852
sexp+block/scope highlighting make readability excellent.
>>
>>57697876
It doesn't matter if you accidentally a type error in a lisp because nobody will ever run the code.
>>
>>57697893
but they have, anon.
>>
>be lisp weenie
>have to use macros everywhere to cover up the deficiencies and limitations of the language and the inability of the compiler to truly help you

>be hasklel/scalel weenie
>compiler can tell you at compile time if you're trying to get a value out of a map with a key that it doesn't contain
>>
>>57697889
Okay grandpa, I'm actually gonna learn SICP and an applicable language instead of a pseudo-pseudo language. :^)
>>
>>57697893
But they have jobs. All those html sites doesn't write themselves.
>>
>>57697701
>"No, John, it can't. Fortunately, 'manipulating code as data' has negligible impact on productivity and is mostly a concern for self-absorbed aesthetes. So while you Lispers masturbate at homoiconicity and metaprogramming, the rest of us are building the software that fuels the modern age. So please, spare us and go back to your retirement home."
>>
>>57697893
if americans are so smart why do pajeets get their jobs?
>>
>>57697966
Because they're hired by dumb people.
>>
>>57697966
If pajeets are so smart why do companies who outsource to them end up having to bring in american consultants to rescue projects?
>>
>>57697952
Yeah I'm pretty sure that's exactly what celebrated Lisp author Peter Norvig said during his presentation on Python metaprogramming.
>>
Ultra abstract engines like GeneXus make programmers deprecated.
>>
>>57696869
>too new
>>
Is there a typed language that has homoiconicity? And I mean with an advanced type system, not something trivial like simply typed lambda calculus.
>>
File: guidosicp.png (100KB, 601x623px) Image search: [Google]
guidosicp.png
100KB, 601x623px
>>57697952
Code as data (and homoiconicity) helped me to resolve a challenge on r/dailyprogrammer. It's a great feature.
>>
File: Capture.png (60KB, 663x660px) Image search: [Google]
Capture.png
60KB, 663x660px
>>57697138
>>
>>57698019
>Guido buttblasted
>>
I'm making a simple command-line game in C#
I wanna get good with C# before I move to Unity
>>
>>57697827
Thanks! I'll order it
>>
>>57698000
any typed lisp
>>
File: rob-pike.jpg (19KB, 500x335px) Image search: [Google]
rob-pike.jpg
19KB, 500x335px
>The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt.
– Rob Pike
>>
File: rob.png (449KB, 838x855px) Image search: [Google]
rob.png
449KB, 838x855px
>>57698089
>>
https://www.youtube.com/watch?v=Bxcz23GOJqc

What did he mean by this, /g/?
>>
>>57696845
The day-of-the-week thing is kind of sad.
>>
>>57698020
How is Rust?
>>
>>57693267
>monads are specific
No they aren't, and monads can do things linear values cannot.

>fallacy
Not every reasonable argument can be put into a syllogism.
>It's a fallacy to say "it's useful so it must be true", so therefore it being useful isn't a good argument for putting it into a language
>>
>>57698089
>implying unix came after google
>implying google was written in lisp
>>
Small gayme in SFML.
>>
File: slide_6.jpg (131KB, 960x720px) Image search: [Google]
slide_6.jpg
131KB, 960x720px
>>57697546

Yeh your image describes it pretty perfectly.

Is there a reason why it's done like this?

BASIC was around before it. Despite BASIC's shortcomings it's still way more popular and in practical use today.

So what was there reason for making it more unreadable than formal language mathematics? Was this just the 1970s version of being an edge lord neckbeard?
>>
>>57698278
>>57697546
reading lisp is like reading haskell
>>
>>57698278

Sorry MicroShitter OS fucked up editing the image amazingly. What I was trying to illustrate is why not over the operator to the middle? I don't get why they made the design choice to have it come first.
>>
>>57698300
there no operator in lisp.
>>
>>57698300
You mean infix operators?
They don't fit into LISP's "elegance"
>>
>>57698300
Never wrote Lisp so I may be wrong but I believe '+' is the name of a function and you always put the name of the function before the arguments.
I love Lsp's syntax. It's so clean. Wish I had a reason to learn it.
>>
>>57698292

It just strikes me that something close to formal language would have been much better, like

(define square(x) => (x*x))


But instead with scheme they went with,

(define (square x)(* x x)


To me the top just looks way more readable and would be something you'd see in Scala say (although I think the syntax would be a little different).

Just seems to me like Scala was the way functional programming should have been done in the first place.
>>
>>57698429
what you want is javascript:
let square = (x) => x * x;
>>
>>57698429
>Scala

scala> List(1, 2, 3).toSet()
res0: Boolean = false
>>
Could someone point me in a good direction to learn R?
>>
>>57698452

Yeh I've been hearing that a lot lately, have you tried much functional JS?
>>
I'm trying to program a function in c that compares to elements in a struct, and if they are equal it needs to store the struct in an array, but I am kind of stuck on the storing it in an array part. Do you guys ave any ideas?
>>
>>57698452
Isn't it
var square = function (x) { return x * x; }
>>
>>57698483
memcpy
>>
>>57698486
That's the old way of doing it. ES6/7's syntax is much more concise.
>>
Employed Haskell programmer reporting in
>>
>>57698480
Just use node.
>>
>>57698486
no

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/let
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions

>>57698480
idk i was just memeing but desu js has a bunch of functional features but the problem is that the rest of js is a steaming pile of crap
>>
>>57698462
East
>>
>>57698462
You don't learn R, you use it. Don't try to do any general programming with it, stay with ggplot2 and plyr.
>>
>>57698491
Thank you I will try that out!
>>
>>57698503
how is your front end developer job? did you learned photoshop CS6 fast enough?
>>
>>57698132
Tooling is great.
Lifetimes are great.
C interop is painful.
>>
>>57698452
In F# this is just
let square x = x * x
>>
>>57698429
It's much simpler language wise though
>>
>>57698555
>>57698452
step aside
square = (*) <*> id
>>
>>57698569
That's once character shorter and much less readable.

Language?
>>
>Java

If I multiple if conditions can I shorten somehow ?

if(month == 1 || month == 2 || month == 3 etc....)

can i write something like month == 1 || 2 || 3 ?
>>
Employed Adobe ColdFusion programmer reporting.
>>
>>57698590
haskell ofc

square = id >>= (*)
square' = do
x <- id
(x *)
square'' = [ (x *) | x <- id ]



i guess there is also
square x = x * x


but that's too readable to be haskell
>>
>>57698594
They used that in my old company. What a steamer...
>>
>>57698591
int[] a = {1,2,3};
if(IntStream.of(a).anyMatch(x -> x == month)) {
}
>>
>>57698622
Can you not put {1,2,3} directly into of(..)?
>>
>>57698627
you can
>>
What's an elegant way to do this:

[1,2,3,4,5.]

with a loop

In C#:

 Console.Write("[");
for (int i; i < 5; i++)
{
Console.Write(i + (i!=4)?", ":".]");

}



what is wrong with this?
>>
>>57698684
haskell is
print [1..5]

so write your own printFinEnumeration function
>>
>>57698684
Not sure if a problem in C# but i is uninitialized.
>>
>>57698712
Yes, forgot to initialize it, thanks.

Still error though.

Operator '+' cannot be applied to operands of type 'int' and 'bool'
>>
>>57698684
just print the [ then the numbers and after the loop you print .]
>>
>>57698556

Yeh I'm reading up on Scheme a bit more now before I continue with SICP

https://people.eecs.berkeley.edu/~bh/ssch7/variables.html

I'm starting to see how it makes higher order functions more readable and elegant
>>
File: mane.png (100KB, 1603x664px) Image search: [Google]
mane.png
100KB, 1603x664px
I'm having problems with saving and printing structs in c correctly. The format of the strings I am copying with fscanf are
R1 Fre 17/07/2015 18.00 FCN - SDR 0 - 2 3.211
Don't worry about the formating in the print, I am only printing to check if it is saved correctly. I am running the function 198 times, because there are 198 games(4 in each round).
The only thing that seems to be printing correctly is that name of the first 30 rounds. Can anyone spot where I am messing up?
>>
>>57698720

What line is the bool appearing ?
>>
>>57698720
The ternary operator has a low precedence, bracket it to stop it involving the addition:
i + (i!=4?", ":".]")
>>
>>57698722
The point is to generate the commas with the loop in an elegant way. If I print a comma after each number, there will be a comma too many at the end.

There must be a nicer way than making an if statement, like ... if last iteration, do not print comma.

Must be a nicer way to do this!
>>
>>57698741
THANK YOU!
>>
>>57698730
in Haskell you can sort of mix the two

(+) x y = x + y
x `f` y = f x y
>>
>>57698684
Also you screwed up the loop start/condition.

IMO just change it to:
Console.Write("[");
for (int i=1; i<n; ++i) {
Console.Write(i + ", ");
}
Console.Write(n + ".]");
>>
When do I need to start worrying about whether to make an object static or dynamic in C++?
>>
>>57698684
How about this?
Console.Write("[" + String.Join(Enumerable.Range(1, 5), ",") + "]");
>>
>>57698817
You mean whether to use regular inheritance or virtual inheritance?

If the way you're designing it hasn't already determined it then use regular inheritance. You should understand runtime polymorphism and what it can do, if you don't need it then don't use it.

Typical thing that requires it is doing pure virtual interfaces, or storing different types of objects in one place as pointers/references.
>>
>>57698840
That would be the preferred way of doing it, unless the questioner is adamant on the "with a loop" requirement.
>>
>>57698840
>>57698855
Thank you telling me about that.

I actually need to create a series of numbers that is not a range, I just gave that as an example

I have a series of random numbers , so >>57698741 still seems like the best solution

Thanks again!
>>
>>57698840
F# would be
[1 .. 5]
|> Seq.map string
|> String.concat ","
|> printfn "[%s]"

although I have it using more lines, it's more readable. Can easily make it one line too.
>>
>>57698874
then just do
Console.Write("[" + String.Join(numberCollection, ",") + "]");
>>
>>57697391
>Gonna get replaced by Elasticsearch
Do you know what solaris is?
>>
>>57698877
haskell:
f =   printf      "[%s]" 
. intercalate ", "
. map show

bonus: because of type class bullshit, printf is also sprintf
>>
>>57698840
>>57698889

This doesn't work for me unless i put the separator on the left argument.
>>
File: bunch-of-faggots.jpg (7KB, 236x236px) Image search: [Google]
bunch-of-faggots.jpg
7KB, 236x236px
>>57698704
>>57698877
>>57698972
He asked for a solution in C#, stop bloating these threads with useless posts!!!!
>>
>>57699021
C# is for faggots like GTP
>>
File: hF6mS.jpg (282KB, 1055x694px) Image search: [Google]
hF6mS.jpg
282KB, 1055x694px
>>57699021
>>
>>57698877
in javascript that's just:
`[${[...Array(6).keys()].join(',')}]`
>>
>>57699029

Do something about it.
>>
>>57699045
Disgusting.
>>
>>57699043
c++ the best language ever
People can say whatever they want, it will always be the best.
>>
>>57699079
so finally the One True Faggot shows himself

you are accused of liking C#

what do you have to say for yourself
>>
>>57699029
>>57699079
selfposting faggot

http://www.strawpoll.me/6954197/
>>
>>57699092
// Declares a function called "myVector" that returns a std::vector<float>.
std::vector<float> myVector();
// Does NOT declare an instance of std::vector<float> called "myVector"

// Declares a function called "foo" that returns a Foo and accepts an unnamed
// parameter of type Bar.
Foo foo(Bar());
// Does NOT create an instance of Foo called "foo" nor creates a Bar temporary

// Declares a function called "myVector" that takes two parameters, the first named
// "str" and the second unnamed, both of type std::istream_iterator<int>.
std::vector<float> myVector(
std::istream_iterator<int>(str),
std::istream_iterator<int>()
);
// Does NOT create an instance of `std::vector<float>` named "myVector" while copying
// in elements from a range of iterators


C++ucks will defend this.
>>
>>57699120
I don't know how people can defend C++, it's just disgusting
>>
>>57698842
>virtual
Practically never use that keyword. Not for dynamic dispatch or anything.
Since C++'s vtables are terrible in every imaginable way (slow, can't be modified while being standard compliant, is practically always a double indirection).
If you want late binding while using inheritance in C++ implement it yourself.

Unless you're using C++ AND you don't care about performance. In which case you should simply stop using C++. Probably. Unless you're really in a hurry and can't learn something else before the deadline.
>>
>>57698684
ez
using static System.Console;

namespace koding {
class Program {
static void Main(string[] args) {
for (int i = 0; i < 5; i++) {
if (i == 0) {
Write("[1 ,");
} else if (i == 1) {
Write("2 ,");
} else if (i == 3) {
Write("3 ,");
} else if (i == 4) {
Write("4 ,");
} else if (i == 5) {
Write("5.]");
}
}
}
}
}
>>
File: beautiful_code.png (348KB, 570x738px) Image search: [Google]
beautiful_code.png
348KB, 570x738px
>>57699148
>>
>>57699120
That makes sense though?
If that did not make sense, how would you declare a function prototype named myVector that returns std::vector<float>? Oh wait... If you need to declare a variable like that use {} instead.
>>
File: 1472036666302.png (311KB, 652x669px) Image search: [Google]
1472036666302.png
311KB, 652x669px
>>57699148
>>
>>57699148
>
using static System.Console;

namespace koding {
class Program {
static void Main(string[] args) {
for (int i = 0; i < 5; i++) {
if (i == 0) {
Write("[1 ,");
} else if (i == 1) {
Write("2 ,");
} else if (i == 3) {
Write("3 ,");
} else if (i == 4) {
Write("4 ,");
} else if (i == 5) {
Write("5.]");
}
}
}
}
}
>>
>>57699148
That should be just:
Console.Write("[");
Console.Write("1");
Console.Write(",");
Console.Write("2");
Console.Write(",");
Console.Write("3");
Console.Write(",");
Console.Write("4");
Console.Write(",");
Console.Write("5");
Console.Write("]");


Why do you men always make things more complicated than needed be?
>>
>>57698684
Wait, why is the last element a float?
>>
>>57699190
Not if you want to test how poor Java's JIT is.
Anyone has experience with inspecting JIT code?
Where can I learn this? I want to laugh.
>>
>>57698743
Only loop n-1 times and do the final step after the loop.
>>
>>57699190
Use ' instead
>>
>>57698972
or just
show [1..5]
...
>>
File: benis.png (3KB, 342x136px) Image search: [Google]
benis.png
3KB, 342x136px
>>57699113

I appreciate your concern.
>>
>>57698772

Interesting, with Haskell were they trying to make the syntax to be less rigid?
>>
>>57699201
What exactly is JIT compilation? I know the full form, but can someone tell me what it intuitively means for a developer? And some pros/cons.
>>
>>57699235
I'm not sure what the motivation for infix functions was (though it's definitely welcome), but being able to turn operators into regular functions is extremely useful for higher order functions

e.g. foldl (+) 0

For infixing arbitrary functions:

3 `elem` [1,3 .. 23]
(+) `on` (*2)

5 `div` 3
5 `mod` 3
-- this could've been the motivation desu


Haskell's really nice for DSLs though, so flexible syntax might've been a motivation
>>
I have an algorithm problem.

It's an assignment, but not for me, it's a freelancer job I was forced to pass on because I didn't know how to do it.

Anyway, here's the task:

You are trying to organize an event for k attendees from among a potential set of n attendees.
The problem is that there are some potential attendees that are absolutely inseparable; they
refuse to go without each other. After extensive discussions with all potential attendees, you
have drawn up a list of pairs (x[],y[]), such that x[i] 6= y[i] for all i, and x[i] will go to the
event if and only if y[i] will go to the event. You need to figure out, given the constraints
above, if it is possible to organize the event for exactly k attendees.

The input file has at most 3000 strings. Each string contains n, the total number of potential
attendees, k, the number of desired event attendees, and and 2 input arrays x[] and y[].

The requirement is that the program runs in 3 seconds or less.

Does anyone know the name of the algorithm to use?

I was thinking about making up the longest chains of attendee pairs and seeing if the combinations of their lengths add up to the desired number, but there's no way something like that can run in 0.1 second.
>>
Linux CFS (Completely fair scheduler) is over 9000 lines of code. Holy shit.

>https://github.com/torvalds/linux/blob/master/kernel/sched/fair.c
>>
>>57699318
>
{
>>
File: just blow my rocket up.jpg (21KB, 327x466px) Image search: [Google]
just blow my rocket up.jpg
21KB, 327x466px
>A* search goes through 76000 nodes to find a path of length 3
>>
>>57699331
try jump point search
that'll probably only take 70000 nodes
>>
>>57699318
Makes sense. Scheduling is unavoidably complicated and difficult. Same as a filesystem or database. Still quite intimidating to see such a monolith to man's desire for scheduled execution of code.
>>
>>57699300
Not sure if this is correct but make a graph G = (V, E)
Where V = {set of all attendees}
E = {(x, y) | x,y is a pair in that array}

You have to now find out whether there exists a connected component with exactly k vertices. Can be done in polynomial time (Linear also maybe).
>>
>>57698292

Lisp is honestly a lot more readable than Haskell to me.

>>57699181
>>57699190

This could all be condensed into one write statement.

using System;
using static System.Console;

public class Program
{
public static void Main(string[] args)
{
Write("[1, 2 , 3, 4 , 5.]");
}
}
>>
>>57699392
familiarity
you should learn haskell
>>
>>57699382
>>57699300
Minor correction.
Make a list of all the connected components as before. Say (C1, C2, C3, ... , Cm)
Now you have to figure out whether you can choose a subset of these components such that the sum of the vertices is exactly k
>>
>>57699392
Lisp has a consistency to it, even in relatively macro dense code.
Haskell, with it's zoo of infix operators and monadic magic, not to mention all the extra language extension, can become a real headache to parse. You sort of have to read it twice to understand it sometimes.
>>
>>57699392
Stop playing retarded, you forgot the loop

public class Program
{
public static void Main(string[] args)
{
for (int i = 0; i < 1; i++)
{
Write("[1, 2 , 3, 4 , 5.]");
}
}
}
>>
File: just fuck my eyes up.jpg (585KB, 1280x1440px) Image search: [Google]
just fuck my eyes up.jpg
585KB, 1280x1440px
>>57699392
>public class Program
>{
> public static void Main(string[] args)
> {
>>
>>57699318
lot of comments, blank lines, {/} lines, ...
>>
>>57697600
(((LISP))) is an extremely Jewish language so of course non-Jews find it difficult to think in.
>>
>>57699469
I agree, but still as this anon said >>57699380 scheduling is pretty complicated. They use some pretty neat heuristics and even change the timeslice duration depending upon the priority.
Truly marvellous.
>>
>>57699426

Thanks, I'll think on it.
>>
>>57699492
The fun part is imagining how long it took them to get it "right".
They say it takes about a decade to mature a filesystem
How long for a scheduling system?
>>
>>57699283
JIT - Just in time compilation (not aimed at you just in general to readers)
Means that a program compiles the program you're writing as you run. In the case of Java it means that the program is partially compiled and pieces of the program are to be compiled on the host machine.

The goal of this is so that the program can be compiled to a more native format and be more appropriately adapted to the machine than it would be when compiled at the developer machine.

The pro's of this tend to be that you:
1.Don't have to compile for different platforms
2. Can potentially yield better results than a direct native compile due to situational constraints.
* The complete compile may be less specific than the JIT, with a JIT you know the complete parameters of the platform you're running on. For instance you may not want to have the users bother with choosing between AVX-512 builds and SSE2 builds, the latter being more common but the former being better usually. With the JIT you get to avoid this. It's kinda the same pro as #1 but not really.
3. You can adapt to dynamic platform constraints.
*Again sounds like the same point and sortof is but lets say you run on a machine with 8-gigs of ram. But another process is hogging 7.7gigs of the memory. A very good JIT could account for this (usually only when the application starts).
4. The programmer doesn't have to care about platform specific details, the JIT does it for them.

(cont.)
>>
is it bad if I don't free() everything before using exit()?
>>
>>57699645
It's bad since it means you don't know what the shit you're doing
>>
>>57699520
In the beginning they had a naiive O(n) scheduler.
Basically, they simply iterated in the list of runnable processes, computed the priorities and picked the best processes and scheduled it. This was clearly not scaleable.

Later, they moved to an O(1) scheduler but it had it's own issues, don't really know a lot about it. AFAIK, it was insanely complicated and used very complex heuristics.

Finally they came up with the CFS which is O(log n), and it's very elegant too. Also, I was a bit wrong when I said they use some neat heuristics and variable time slices. CFS doesn't require any heuristics.

O(n) sched - https://en.wikipedia.org/wiki/O(n)_scheduler

O(1) sched - https://en.wikipedia.org/wiki/O(1)_scheduler

CFS - https://en.wikipedia.org/wiki/Completely_Fair_Scheduler
>>
>>57699636
The Cons:
1. The JIT needs to run.
* The JIT is a compiler, inside your program. It needs to run to produce the stuff the CPU needs to run. Simple.
2. Often incredibly hard to implement without certain surrounding assumptions.
*Garbage collection is one thing that makes JIT easier to handle. The less specific the code the programmer specifies the more room for the JIT, the more oppurtunity for JIT optimization.
3. The programmer often can't care about the platform specific details
* Note how this is similar to point 4 among the pro's. If you're a person who can and want to optimize your program to perfection there's very rarely a JIT environment which lets you. In the case of Java it's not standard to let the JIT run in certain parts and let the JIT not run in other parts. So when you write your program you have to consider its interraction with the JIT, which is often incredibly hard to impossible if you don't control it. And when you do it becomes a project of making your JIT work out all the code the right way. Things like offline processing might not be entirely possible without metaprogramming facilities in the case of Java. It's harder to bake in values properly.
* Android as a platform allows you to write C or C++ code inside your Java based app using their Android NDK. The interactions between the Java layer and C or C++ layers are not many and they're not particularly convenient. So the model tends to be to place very performance critical parts in the C or C++ code if you can manage it better than JIT or you simply end up writing your entire application in the NDK and the Java layer is just there becasue android demands it.
>>
>>57699520
9 months i think
>>
>>57699300
Branch and bound.
Thank me later.
>>
>>57699645
Not really. If you have a clearly defined exit point.
Like when you have a game and the player has pressed the "exit" button.
If you're done with saving or whatever don't bother freeing stuff. The OS does it for you now.

And I wouldn't care for people who run on machines where the OS doesn't retrieve the memory when the application exits. That's something you concern yourself with when you face that, not before.
>>57699661
That's wrong and you know it.
>>
>>57699645
Depends, if the process is a child process of another one of your* processes.
Because if the parent doesn't wait, it is essentially a memory leak. A process that has exit()ed but if its parent hasn't wait()ed then it's known as a zombie process.

* - your process means that you're explicitly calling fork(). If you ran the process from say, a shell, then the shell's code contains the wait() call.
>>
>>57699331
you probably fucked up the heurestic
>>
>>57699398

The only thing learning Haskell would do for me is being able to understand all of you guys' shit.

>>57699666

If you're going to make notes about Android, you should add on that Android doesn't do JIT. All bytecode gets compiled AOT at install time. When you first launch an application, you're launching a native binary.
>>
>>57699645
It's OK if you're a code monkey.
>>
File: B9FOyj2IYAAdnAm.jpg (21KB, 473x328px) Image search: [Google]
B9FOyj2IYAAdnAm.jpg
21KB, 473x328px
>>57696619
>What are you working on, /g/?
Refactoring and restructuring my kernel.
>try to make everything prettier and more intuitive
>end up with something even worse that doesn't compile
>>
File: 844581242.jpg (34KB, 192x220px) Image search: [Google]
844581242.jpg
34KB, 192x220px
>tfw you like programming, but you're a complete retard when it comes to algebra
>>
>>57699746
>The only thing learning Haskell would do for me is being able to understand all of you guys' shit.
learning is its own reward
>>
>>57699746
>android doesn't do JIT
I'm not sure if that's true actually.
I've avoided Java as much as possible but when looking into it I recall looking at
https://developer.android.com/reference/java/lang/Compiler.html
The first method (command) there seems to indicate that there may be Android JIT. But I never aimed to do that so I didn't look into it.
>>
File: squidward.jpg (113KB, 1152x864px) Image search: [Google]
squidward.jpg
113KB, 1152x864px
>>57699791

>falling for the "you need math to be a programmer" meme
>>
>>57699791
Nigger, a sixth grader can do algebra. YGSIU.
>>
>>57699791
you will do great I promise anon.
Just don't become a CS student. CS isn't programming.
>>
>>57699826
But CS is the degree with the best job prospects.
>>
>>57699764

Why does this guy use the * character in place of the = character?

>>57699797

There are many more interesting things I could spend my time learning.
>>
>>57699846
>Why does this guy use the * character in place of the = character?
no idea
>>
>>57699733
After applying the landmark optimization to the heuristic I got it down to 965.
>>
>>57699764
Weak and dynamic typing are cancers that lead to unnecessary bugs. Static, strong typing is the only sensible way to create a language.
>>
>>57696619
>What are you working on, /g/?
Trying to create strong, self-aware AI in Haskell.
>>
>>57699842
>wants to be a programmer
>thinks he needs a degree
Another meme.
>>
>>57699810
Being good at math certainly makes things easier
>>
>>57699846
You're incapable of learning Haskell, aren't you?
>>
>>57699866
Pretty sure ekmett has already added that as a hidden feature in the lens library.
>>
What's the biggest project you guys have completed in non-imperative languages?
Just curious.
>>
>>57699901
he wasn't alone
>>
>>57699824
this has to be bait
>>
>>57699666
So when I do
$ javac Main.java
it doesn't actually produce the machine code? And that's the reason why I can give the .class files to someone on a different architecture and OS and still they would work by doing
$ java Main.class
So does `java' finish the compilation and then run the program?
>>
>>57699808

I know old versions of Android (before Lollipop) did JIT, and I'd imagine if you could somehow get a class into the program AFTER the install process, it might be able to JIT it, but in general, Android shouldn't be doing any JITing. That's work it handles at install time to ease startup lag.

>>57699891

Uninterested. It literally serves me no purpose. I didn't bother to learn Prolog either until I had a professor decide that we were going to use Prolog for the first couple of assignments. I also desire to never learn COBOL if I can avoid it.
>>
>>57699972
it will change the way you think about code, functions and types
>>
>>57699902
I wrote a tool to assist me in grading standards-based exams and translating standards-based grades to conventional letter grades.

The place where I teach doesn't do standards-based grading, but the curriculum we use kinda assumes that we do use standards-based grading. The tool I wrote gives me test averages and also breaks down a student's mastery on a per-standard basis as well as giving me a picture of a class's mastery on a per-standard basis.
>>
File: juxwtf-japan-funny-butt-gun.gif (1MB, 480x270px) Image search: [Google]
juxwtf-japan-funny-butt-gun.gif
1MB, 480x270px
>>57697600
then tell us sir rottingman computer scientist, how many wonderfull operating systems and co. are done with functional programming?
>mfw the cpu only know to sum and point memory, while giving a fuck about lambda calculus
>>
>>57699902
Wrote a prolog program to find solutions for a 3x3 magic square for a class assignment. Maybe about 20 lines of code.
>>
>>57696660
go through sicp so you can pretend to be a Real Hacker
>>
>>57699951
No it's as it says, just in time.
When you call Javac you compile some of the code. I don't know how much or really much at all about the format. But it compiles some.
When you do
Java Main.class you invoke the Java virtual machine and asks it to run your main.class file.
Under normal circumstances all Java programs run in the virtual machine. It can be built into the executable (like you'd see with minecraft usually) or you have it pre-installed on the computer.

While the Java virtual machine then handles your .class file and produces the code the CPU actually runs. I'm not sure if there's particularly many 'setup' steps where it compiles a lot to start with or if it just compiles small chunks at at time. But since it can run on any platform with a Java virtual machine available none of it is actual machine code in the .class file.
>>
>>57700078
>just in time.
Holy shit I think I finally get it. You're literally compiling on the fly as you run. Holy fucking shit.
>>
>>57700078
>you invoke the Java virtual machine and asks it to run your main.class file
Ok so, is Java like an 'interpreter' for the Java bytecode? Then how is Java `efficient'? I mean surely compiled assembly must be much more efficient than a virtual machine running the bytecode...or should it?
>>
>>57700141

You ever hear people talking about a Java server/benchmark/etc being 'warmed up'? This is because virtual machines (including the JVM) can do a lot of magic.
>>
>>57699951

More or less. What javac produces is Java bytecode. It's more or less a stack-based assembly language of its own that the JVM knows how to translate into native code.
>>
>>57698590
>>57698601
>one character shorter and much less readable
>haskell ofc
Pretty much defines the whole language.
>>
>>57700279
it was a joke anon
square x = x * x

is also valid
>>
>>57700279
>Pretty much defines the whole language.
Tools like the aptly-named "pointless" make it very easy to convert perfectly good code into an unreadable pointfree mess.
>>
>>57700185
>I mean surely compiled assembly must be much more efficient than a virtual machine running the bytecode
Not quite right there.
I'm not really a good educator on Java, as I only really know it from avoiding it.

But the java compiler (javac) I'd imagine they do some compilation steps you'd normally do in compilers like all the transformations from text to something a computer understands a little better, eliminate dead code, inline code or whatever.

Then it produces a class file which is a 'prepared' file for the Java virtual machine. So that program doesn't have to do the steps I imagined it would have to do. They then, using the class file and the JVM write the actual stuff you'd find in a normal platform specific executable file into memory, asks the CPU to execute it and it does.
So it's an interpreter for the java byte code in some respect yes. But it still asks the CPU to execute machine code. I don't imagine the JIT is actually a big issue on modern computers. We have multiple cores, most programs don't use it effectively enough to be bothered by the JIT. And compiling a program that's already prepared to be java bytecode shouldn't take much processing at all in theory not take much processing at all.

But you will find that performance oriented people often steer away from java just because they can't control it. If it doesn't work well enough when you've written your program sortof to a shippable state it's difficult to make it run faster.
With C or C++ you can do that and usually there's tons and tons of headroom to go insane working late nights over. So that's somehow preferable in this masochistic profession. But not for rad java dudes who go to parties and have sex with females and stuff.
>>
>>57700185
Oh and assembly isn't machine code. It's a machine code representation made to be easy to read for humans.
>>
Can you guys recommend me a good guide to C makefiles?
>>
Trying to figure out how to write a header library. Could probably use some assistance.

testlib.h
#pragma once
#include <iostream>

template<typename T=int>
void PrintFoo(){std::cout << "Foo!" << std::endl}


Is this how it's done? It seems to work, but it doesn't look right. Especially with the default type int because it wouldn't accept void.
>>
>>57700504
>typename T = int
What is that supposed to do?
What is even the purpose of the template?
>>
struct ICE
{
char *str;
};

void ICE_init(struct ICE *ice, const char *str)
{
ice->str = strdup(str);
}

------
------

int main(void)
{
const char name[] = "George";
struct ICE ice;
ICE_init(&ice, name);
-----
-----
}


gives me this error:
assignment makes pointer from integer without a cast [-Werror=int-conversion]
ice->str = strdup(str);

It compiles with a warning without -Werror but works as expected otherwise.

pls help a noob out
>>
>>57700504
>
template<typename T=int>

This, if I recall correctly defines a template specialization for when the following function takes an int.
>
void PrintFoo(){std::cout << "Foo!" << std::endl}

This doesn't use the T value at all. So remove the entire line with the template typename T stuff.
You're also missing the semicolon at the end of std::endl
>
#pragma once

Makes it so when you include the file in multiple places it doesn't cause issues
>
#include <iostream>

Includes iostream which you need for std::cout.

Now what is your major malfunction, numbnuts?
>>
>>57700478

https://www.gnu.org/software/make/manual/make.html#Introduction
>>
>>57700579
put this at the top of the file
#define _GNU_SOURCE
>>
>>57697260
>>57697284
it's hopoo
>>
>>57700579
No your code is correct. But it doesn't compile in C89.
>>
File: huehue.gif (1MB, 480x270px) Image search: [Google]
huehue.gif
1MB, 480x270px
>>57700366
>But not for rad java dudes who go to parties and have sex with females and stuff.
>>
>>57700621
thanks!
>>
>>57700537
>>57700602
The idea with a header library is to make inclusion of the library as simple as just #include the library, and not having to bother the compiler and linker with it.

The purpose of of the template line is to allow having the implementation in the h file without having the linker complaining about multiple redefinitions when you include the file in several translation units.

The whole typename T=int bit i just put there to make it compile, and that's what i'm asking about. Is there a nicer way of doing that?
>>
File: 1439529964106.jpg (1MB, 1800x1198px) Image search: [Google]
1439529964106.jpg
1MB, 1800x1198px
>>57700623
>hopoo
Really?
I didn't feel that way about him in this picture.
He should watch out.
>>
>>57696619
normie here with some beginner lvl experience in c++, what is the best language to start with and what is the most widely used one
>>
what is the m4 thing i have seen in loads of C projects?
>>
>>57700686
Haskell
>>
>>57700686
Befunge
>>
>>57700686
malbolge
>>
>>57700686
Do these considerations:
-domain
If you're doing webdev you learn webdev langauges.
If you're doing videogames you do videogame languages
If you're doing homo-code you do Swift or object-cocks
-aim
Do you want to be the 'best' or do you want to get a job. For instance if you were to be a videogame programmer and make a lot of money because you're a rare and important person you learn C or C++ (and tons of other non-language specific things). If you don't care so much about that and just want to work on videogames (see picture). C# may be far more appropriate because it's the language unity and a lot of other engines are bound to use in the future.
-enjoyment
Maybe you've found you enjoy certain types of programming even if you're just a beginner. If you can put words to that that's good.

Then when that's done look at what's popular within certain fields, usually there's stats somewhere. Email google and ask them what you should learn or whatever. Look around.

I recommend C regardless of all these considerations.
Or javascript if you're into web. I don't care then.
>>
File: 1418226836357.jpg (37KB, 251x242px) Image search: [Google]
1418226836357.jpg
37KB, 251x242px
>>57699810

>falling for the "you don't have to be really good at math to be a programmer" meme
>>
new thread when? :3
>>
>>57700840
>good at math
Good at understanding math when explained to you VS good at making math your bitch.
There's a difference.
>>
>>57700850

>implying P != NP
>>
>>57700871
I don't know. Explain it to me.
>>
File: 1478668757188.png (253KB, 900x900px) Image search: [Google]
1478668757188.png
253KB, 900x900px
>>57700850
I'm good at golfing perl
>>
>>57700909
>>57700909
>>57700909

NEW THREAD
NEW THREAD

>>57700909
>>57700909
>>57700909
>>
>>57700871
>implying P == NP
>>
Can I make a decent career out of linux kernel hacking?

In terms of salary and benefits, would I be better off specializing in something else and keep kernel hacking as a hobby?
>>
>>57700817
im mainly interested in operating systems and how they work, i see that windows is mainly c++ so i think i'll stick with that for a while
>>
>>57697966
>if americans are so smart
unreachable code detected
>>
>>57698113
barf at the second photo
Thread posts: 332
Thread images: 35


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