[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: 327
Thread images: 39

File: dpt_flat.png (102KB, 1000x1071px) Image search: [Google]
dpt_flat.png
102KB, 1000x1071px
Old thread: >>60380424

What are you working on, /g/?
>>
File: 1483533362817.png (719KB, 1280x715px) Image search: [Google]
1483533362817.png
719KB, 1280x715px
Rewriting C in Idris.
>>
File: 1494685007840.jpg (21KB, 500x500px) Image search: [Google]
1494685007840.jpg
21KB, 500x500px
Can /dpt/ solve this in one (ONE) function?
I was wondering how would you go about subtracting generic types. For example, the function (let's call it "without") should be able to pass the following tests:

assert([12, 23, 23, 11, 5, 23].without(23) == [12, 11, 5]);
assert("ccxi".without('x') == "cci");
assert("abcderfiibcne".without("bc") == "aderfiine");
assert(["siwwo", "lkaiwmn", "diw"].without("iw") == ["swo", "lkamn" "d"]);
assert(['c', 'd', 'd'].without('d') == ['c']);
assert([234, 301, 322].without(12) == []);
>>
File: 1467054649374.png (336KB, 804x900px) Image search: [Google]
1467054649374.png
336KB, 804x900px
re-writing rust in go
>>
File: dlang_chan.jpg (139KB, 470x545px) Image search: [Google]
dlang_chan.jpg
139KB, 470x545px
Threadly reminder that dlang-chan is not dead; she's going to have her GC tumor removed (eventually); and she's super duper cute and easy to prototype in! Say something nice about her, /dpt/!

>>60383798
Please, don't post shit girls.
>>
>>60383788
Can a rust enthusiast give me a few reasons to learn rust? I'm looking to learn a new language and something to replace C could be interesting.
>>
>>60383824
>Please, don't post shit girls.
>Posts shit girl anyways
>>
File: 1436388980604.png (258KB, 549x560px) Image search: [Google]
1436388980604.png
258KB, 549x560px
>>60383806
>subtracting types
Sorry?
>>
>>60383804
Wew. Thanks.
>>
>>60383829
Rust is not a revolutionary language with new cutting-edge features, but it
incorporates a lot of proven techniques from older languages while massively
improving upon the design of C++ in matters of safe programming.
The Rust developers designed Rust to be a general-purpose and multi-paradigm
language. Like C++, it is an imperative, structured, and object-oriented language.
Besides this, it inherits a lot from functional languages and also incorporates
advanced techniques for concurrent programming.
In Rust, the typing of variables is static (because Rust is compiled) and strong.
However, unlike Java or C++, the developer is not forced to indicate the types
for everything as the Rust compiler is able to infer the types in many cases.
C and C++ are known to be haunted by a series of problems that often lead to
program crashes or memory leaks which are notoriously difficult to debug and solve.
Think about dangling pointers, buffer overflows, null pointers, segmentation faults,
data races, and so on. The Rust compiler (called rustc ) is very intelligent and can
detect all these problems while compiling your code, thereby guaranteeing memory
safety during execution. This is done by the compiler by retaining complete control
over memory layout, without needing the runtime burden of garbage collection
Rust compiles native code like Go and Julia. However, in contrast to these two, Rust
doesn't need runtime with garbage collection. In this respect, it also differs from Java
JVM and the languages that run on the JVM, such as Scala and Clojure. Most other
popular modern languages such as .NET with C# and F#, JavaScript, Python, Ruby,
Dart, and so on, all need a virtual machine and gc.
As one of its mechanisms for concurrency, Rust adopts the well-known actor model
from Erlang. Lightweight processes called threads perform work in parallel. They
do not share heap memory but communicate data through channels, data races
are eliminated by the type system
>>
>>60383858
ctd
These
primitives make it easy for programmers to leverage the power of many CPU cores
that are available on current and future computing platforms.
The rustc compiler is completely self hosted, which means that it is written in
Rust and can compile itself by using a previous version. It uses the LLVM compiler
framework as its backend (for more information on LLVM compiler framework, go
to http://en.wikipedia.org/wiki/LLVM ) and produces natively executable code
that runs blazingly fast because it compiles to the same low-level code as C++ (To
see an example of its speed, go to http://benchmarksgame.alioth.debian.org/
u64q/rust.php .).
Rust is designed to be as portable as C++ and run on widely used hardware and
software platforms; at present, it runs on Linux, Mac OS X, Windows, FreeBSD,
Android, and iOS. It can call C's code as simply and efficiently as C can call its own
code, and conversely, C can also call Rust code
>>
>>60383834
Please, don't post about your shit taste.
>>
>>60383858
>the typing of variables is static
So like every language?
>Rust is compiled
So like every language?
>>
>>60383883
>Rust is compiled
>So like every language?
hmmmmmmm made me think
>>
>>60383829
Rust is worth picking over C++, not C. C is not replaceable.

Also Rust is not worth it if you use GC'd language, since it solves almost nothing (emphasis on almost) over a GC'd language
>>
File: goodmeme.mp4.webm (2MB, 1920x1080px) Image search: [Google]
goodmeme.mp4.webm
2MB, 1920x1080px
>>60383788
>What are you working on, /g/?
got muh oled display working on plain C with an atmega8, no arduino shit anymore
>>
File: ran_tewi_wink.png (82KB, 350x238px) Image search: [Google]
ran_tewi_wink.png
82KB, 350x238px
>>60383806
>for any generic S of type T and the deletion generic s define F as the set of endomorphisms f: S → S and G as the set of epimorphisms g: S → s
>let H = F\G then return the image of morphisms in H
>>
>>60383883

JavaScript is a programming language, but it is neither compiled (at least not ahead of time), nor is it statically typed.
>>
>>60383937
Teach me senpai
>>
>>60383858
>>60383878
Looks like buch of PL autists made a Frankenstein 2bh
>>
>>60383806
>
assert([234, 301, 322].without(12) == []);

are you sure this test case is correct?
>>
>>60383806
>mfw even quora can solve this
>>
>>60383858
>>60383878
>>60383914

So, how does the speed of rust compare with C++? Also, could I use a library compiled with C linkage with a rust program?
>>
>>60383942
>it is neither compiled
Impossible.
>nor is it statically typed
Also impossible. You simply can't create a programming language which is not statically typed.
>>
File: 1494592459187.gif (2MB, 270x188px) Image search: [Google]
1494592459187.gif
2MB, 270x188px
>>60383983
https://doc.rust-lang.org/book/ffi.html
>>
>>60383983
Nevermind, I didn't see the last part of >>60383878
>>
>>60383994
top snek
>>
>>60383977
You could return a null (preferably) or the whole array intact
>>
>>60384015
should it be
assert([234, 301, 322].without(12) == [234, 301, 322]);
?
>>
>>60384026
Yeah, I wouldn't prefer that but I guess I can consider that
>>
File: concur.jpg (521KB, 900x1227px) Image search: [Google]
concur.jpg
521KB, 900x1227px
I made some 90s style box art for my currency converter script
>>
File: 1492616007973.jpg (9KB, 200x218px) Image search: [Google]
1492616007973.jpg
9KB, 200x218px
>>60383994
I want to protect that snek!
>>
>>60384107
Sasuga /g/
>>
>>60383993
Muh unityping.
>>
>>60383993

Well check this out...

rubyist@Overmind:~/cs/scratch$ cat hello.js 
var x = 5;
console.log(x); // Prints 5
x = "hello";
console.log(x); // Prints hello
rubyist@Overmind:~/cs/scratch$ nodejs hello.js
5
hello


I assigned a number to x first, and then assigned a string to it. Didn't get an error. If it was statically typed, that shouldn't be allowed.

I also ran it in one command without first generating a binary. It just ran as is. That's not something that occurs in ahead of time compiled languages...

This is one of the more popular programming languages out there, and yet it is neither compiled nor statically typed. Imagine that!
>>
>>60383878
Can you make an application in C or C++ and then import them to a rust project and potentially find segmentation faults?
Or would it just magically fix it?
>>
>>60384038
assert([[234,12], [301,121,12], [322]].without(12) == ?);
>>
>>60384213
Exclude C++, Only D can interface with C++ correctly.

Now if the C program itself segfaults you cannot do anything about it. If you use a gtk wrapper, Rust won't solve any of gtk's issues
>>
>>60383914
C++ doesn't need GC either what is your point?
>>
>>60384228
return [[234,12], [301,121,12], [322]]
>>
>>60384156
It sounds like you've never heard the "every dynamically typed language is actually just a statically typed language with one type" argument.
>>
>>60384232
Yeah, C++ hot other issues in itself. The convenience GC provides nullifies most of Rusts safety restrictions/features.
>>
>won't solve any of gtk's issues
Nothing can.
>>
>>60384240
wtf man you're program spec makes no sense then
should it not be
assert(["siwwo", "lkaiwmn", "diw"].without("iw") ==(["siwwo", "lkaiwmn", "diw"]);
>>
>>60384249

I have, and it's a shitty argument. Besides, there would not be a need to have the term "static typing" if it were a property of all languages. The existence of the term implies an opposite.
>>
>>60384262
No
>>
@60384156
>If it was statically typed, that shouldn't be allowed.
Static typing doesn't say anything about how the program is type-checked. I know you're pretty retarded, but that's a new low even for you.
Static typing (there is no other kind) simply refers to the typing rules of the language. Which are in the head of the programmer and preferably also in some form of static type-checking, though there are retarded languages like r*by and *s which don't do static type-checking. That doesn't somehow mean that the typing rules are now "dynamic".

>>60384249
"dynamic typing" only makes sense if you mean that your language constantly switches between type systems. The number of types it has doesn't play a role here.

@60384280
>there would not be a need to have the term
There is no need to have it. Retards such as yourself just can't use words correctly.
>>
How much would I have to pay to dick Ruby? She's pretty cute.
>>
>>60384229
Okay.
It would be cool to have the application automatically print the backtrace without having to crash the application in a debugger.
>>
>>60384287
please provide a description of the problem, your test cases are not enough
>>
>>60383858
I was under the impression that Julia was interpreted.
>>
@60384291
>being this much of a static typing fanboy

I think you need to go back to r e d d i t.

Seriously, they have a huge hard-on for static typing.
>>
>Play hardbass
>Productivity skyrockets
So this is the power...of the russian hackers? Whoa!
>>
>>60384318
How can you be a "fanboy" of something every possible language already has?
I am a static type-checking fanboy though, and your kind (pl*bbitors) usually don't like it.
>>
The program should
1. Strip a string out of string[]
2. Strip a char out of char[]
3. Strip an int out of int[]

It's not even the entirety of the problem I have for /g/
>>
>>60384291
Who are you quoting?
>>
>>60384302
>>60384344
>>
>>60384347
The "person" I am replying to.
>>
File: shot0033.jpg (310KB, 1920x1080px) Image search: [Google]
shot0033.jpg
310KB, 1920x1080px
/dpt/-chan, daisuki~

Ask your favorite programming literate anything (IAMA).

>>60384291
>Static typing (there is no other kind) simply refers to the typing rules of the language.
No, that's the type system. Static typing is just the type system applied in the static environment.

>>60384249
Untrue.

>>60383788
Thank you for using an anime image.
>>
>>60384356
>type system applied in the static environment
Also known as "type-checking". Not to be confused with "type system".
>>
File: 1493724474608.jpg (27KB, 635x356px) Image search: [Google]
1493724474608.jpg
27KB, 635x356px
>>60384356
>>60383806
>>
trying to implement simd sorting of 32-bit integers

merge sort seems to be the fastest way i guess
>>
File: ((())).jpg (79KB, 524x648px) Image search: [Google]
((())).jpg
79KB, 524x648px
>tfw your faggot professor marks this book as a requirement for your summer semester
>tfw this new """edition""" was only released because the 7th edition is all over the internet

I fucking hate kikes, and there's no way I'm paying $250 for a book that I will NEVER use (seriously, I spent $500 on books last semester and only used one!)

Anyone got a download link or wanna share a digital copy? I've looked on libgenesis and a few private trackers to no avail
>>
>>60384344
Oh also,
0. Strip a string from string
>>
>>60384352
Who is that?
>>
>>60384378
just stick with the 7th edition until some 8-th edition shit comes up senpai
>>
>>60384380
I don't know. But you can probably find her by checking the post numbers I prefixed with '@'.
>>
>>60384378
So if there was no point in the eighth edition and the seventh is everywhere... use the seventh.
>>
>>60384291

>Static typing doesn't say anything about how the program is type-checked

http://wiki.c2.com/?StaticTyping

>Static typing is very often misunderstood to mean that values are associated with types at CompileTime, when instead it means that that a ReferenceValue is manifestly (which is not the same as at CompileTime) constrained with respect to the type of the value it can denote, and that the language implementation, whether it is a compiler or an interpreter, both enforces and uses these constraints as much as possible.

Relevant portion:

>ReferenceValue is manifestly constrained with respect to the type of the value it can denote

So no, you can't do this in a statically typed language:
x = "hello";
x = 5;
>>
>>60384384
>>60384391
I'd do that, but class is tomorrow and the homework is based on problems found only in the 8th edition
>>
>>60384394
dynamic x;
x = "hello";
x = 5;


Valid C#.
>>
>>60384356
>Untrue.

Not if you use retarded definitions!
>>
>>60384386
Eh, effort.

>>60384394
If people actually wrote more programming languages instead of porn downloaders, they'd use the term 'manifestly typed' and be aware of the fact that the crux is associating types with variables, rather than just values.

>>60384401
Just download the seventh and get the exercises off someone who has the eighth.
>>
>>60384298

Create a SIGSEGV handler which uses execinfo.h backtrace() and friends to produce a backtrace.

You can also enable core dumps and inspect those with the debugger afterwards.
>>
>>60384408

There is a phrase used to refer to many .NET languages, and that is "gradually typed". The reason for that is that while the languages use static type checkers for the most part, the .NET ecosystem has a lot of runtime type information available, and therefore, it is possible to circumvent the type checker by using the object type for everything.
>>
>>60384413

Too bad. The term agreed upon by both the industry and academia for a language that provides a static type checker is "statically typed". Your opinion of this is irrelevant -- that is the definition of the word.
>>
@60384394
>http://wiki.c2.com/?StaticTyping
Irrelevant trash.
>So no, you can't do this in a statically typed language:
I can create a language with any type system I want, and since a type system is by definition static, you can.
You wouldn't be able to do this in a statically type-checked language though, but I hope you aren't mentally ill enough to claim that "type-checking" and "type system" are even remotely similar words.

@60384435
>Your opinion of this is irrelevant
Your abuse of terminology and twisting of words is irrelevant.
>>
File: anime pic.jpg (71KB, 400x465px) Image search: [Google]
anime pic.jpg
71KB, 400x465px
>>60384378
>Buying textbooks
>Ever
I'm not an burgercuck, so maybe the "culture" of this shit is different where I live, but I've only ever bought a single textbook, and it literally only cost $20.
Basically all of my courses didn't even mandate a textbook. There might be a "recommended reading", but it only went as far as that. Even in the rare case there was a "required" textbook, you could pretty easily get by without it.
>>
>>60384435
>excessively confrontational towards someone agreeing with you
Whoops, forgot I was on 4chan again.
>>
>>60384447

>Your abuse of terminology and twisting of words is irrelevant.
I am merely using the terminology that everyone else uses. The definition of words is based on how people are using them (otherwise, the word "inflammable" might rightfully mean "non-flammable"). So you can make whatever arguments you want about what the term "static typing" SHOULD mean, your words are irrelevant. The only thing that matters is "what are people in the real world referring to when they use this term?"

Let's look at what the University of Washington, one of the top computer science universities in the country, has to say about this...

http://courses.cs.washington.edu/courses/cse341/04wi/lectures/13-dynamic-vs-static-types.html

>[A static type system is a] tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute.

>A dynamically typed language is one in which type-incorrect operations are caught during program execution, rather than during a type checking phase that precedes execution.

Do you claim to be more authoritative on this subject than professors at the University of Washington?
>>
@60384498
>I am merely using the terminology that everyone else uses.
Which doesn't make it less retarded.
>Let's look at what the University of Washington
Irrelevant trash.
>Do you claim to be more authoritative on this subject than professors at the University of Washington?
I do.
>>
Good PHP challenges / tasks for the beginner?
>>
>>60384506

>I do.
Do you have a PhD in computer science? From what university? On what subject is your dissertation?
>>
>>60384498
>>60384506
linking these posts for readability
>>
>>60384526
>the tripfag thinks degrees mean anything but a waste of money
cute.
>>
@60384526
>Do you have a PhD in computer science?
Nope. I am more authoritative on this particular subject though, simply because I'm correct.
>>
>>60384535

So, having no credentials whatsoever, you make the claim that everyone in academia and the industry are wrong about the definition of a word?

That's cute.
>>
>>60384557
>easily confusing people and sucking up to authority
cute.
>>
>""credentials""
>>>/r/abbit/
>>
>>60384526
My professor wants me to write one, but I don't think it is worth it.
Is there any upsides to having a PhD if you don't want to teach?
It seems like you are less likely to get hired in consulting or rnd positions and I don't want to start my own thing and I don't want to teach people.
>>
Im writing again scheme interpreter. Yesterday i was trying to make my custom lang with flex/bison but only thing i did get out of it is fact im missing some knowledge... I would understand my problems if i didnt have required courses at uni as undergrad, but i forgot everything...
>>
>>60384593
Good thing you have notes from that time.
>>
File: challenge.jpg (61KB, 858x345px) Image search: [Google]
challenge.jpg
61KB, 858x345px
hey /g/, I'm doing the Advent of Code just for fun, looking for some help. Problem for day 16 is basically perform a checksum on some digits. I got the first part right, but now for the second one I have to do a checksum for a binary number that is 35651584 digits long. It was designed to be so big to make you run out of memory, which is what happens to me. So what are some ways of dealing with huge data without running into such problems? How could I get around this?

Btw, my solution to the first part is just some for-loops on Python.

Here's link to the problem:

https://adventofcode.com/2016/day/16
>>
>>60384608
I dont, well i can find them... Thanks god there are books all over internet. I always had great short term memory so i always manage to score well but week after i dont rememeber a thing. I think its a curse.
>>
>>60384584

>Is there any upsides to having a PhD if you don't want to teach?
Yeah, plenty of industry research institutions (i.e. Microsoft Research) only hire PhDs. A PhD is a research degree. If you want to do research, you get one. Otherwise, you can get away with just a BS or an MS and a few years of experience in programming.
>>
>>60384593
Scheme is dead simple. Implementation language?
>>
>>60384630
Yeah it is, its super easy thats why im starting from it. Scheme isnt a problem, problem is i cant apply my knowledge to non scheme languages... Tried to make bastardized version of python yesterday. It failed as anything but more advanced calculator.
>>
>>60384584
it does open up some doors, but you have to wonder whether 5 years minimum (some people take 6 or 7 to finish their PhD's) of eating shit and making no money, possibly getting into more debt, is actually worth it. Most people going into PhD's end up hating their field, but they've invested so much they don't wanna quit. Me, I got out after the 1st year, realized it was just bullshit all the way through. Not a computer PhD, but still related.
>>
>>60384593
There's not too much to it. Just gotta parse Lex it, yacc that into some interpretable form, then interpret it. You don't even need to use those tools, you could implement your own recursive descent parser.

Admittedly though the harder part is probably the runtime.
>>
>>60384644
What is your implementation language?
>>
>>60384648

>possibly getting into more debt
If you are borrowing money while pursuing a PhD, you're doing things wrong.
>>
>>60384653

I think ill go and implement everything by myself, lexer should be easy. Parser ill manage.

>>60384656
Dunno i usually prototype shit in python before translating into C++, so if i get interested it will be C++
>>
>>60384644
>It failed as anything but more advanced calculator.
It succeeded then. Python is itself just an "advanced" calculator.
>>
>>60384668
What have you written so far?
>>
>>60384627
I am completing my masters now, and will work for a while for the university as research assistant while I decide.
I feel a bit burned out with the 90h work weeks, I don't know if it is worth it to do that for three more years.
And a master + 3 years experience seems to be more desired by companies with large engineering teams.
>>
>>60384659
I didn't get into debt, but plenty of my classmates did. We all had a schollarship (about $20k/year) and tuition waiver, but some idiots couldn't live by on that and went out and got a few more loans.

>>60384678
I think this is enough, a masters shows you're not a complete retard who just coasted by as an undergrad. Agreed that experience is more important than the extra research years.
>>
>>60384678

>And a master + 3 years experience seems to be more desired by companies with large engineering teams.
If you are focusing on programming, stick with the master's + experience. Only do a PhD if you want to do research.
>>
>>60384648
Here, it would be 3 years and I would get paid during that time.
I would get 2.7k / month where if I worked elsewhere I would get 3.7-4k/month
Right now, I am a student and I get 600/month which is livable but not great by any means.
So the economical side of it is not an issue for me.
For me, it is a lot of time. The university is closed ~3 months / year which means when you do work, you work all the time.
>>
File: hYMIItH.png (142KB, 511x564px) Image search: [Google]
hYMIItH.png
142KB, 511x564px
>>60384394
as usual with c2, it's more confusing than enlightening. any programming literate shall disagree with this.
>>
>>60384668
http://norvig.com/lispy.html
>>
>>60384744
As usual, the smug anime poster has no idea what other programmers actually think.
>>
>>60384716
How unlikely is it to get a PhD once you have been contaminated by a real job?
>>
File: 1373694480124.png (284KB, 696x542px) Image search: [Google]
1373694480124.png
284KB, 696x542px
>>60384761
i do and most think wrong.
>>
>>60384573
Seconding this.
>>
>>60384675
I've got lexer done, but its code is shitty so im fixing it
>>
File: 1445210682445.jpg (84KB, 960x540px) Image search: [Google]
1445210682445.jpg
84KB, 960x540px
>>60384774
What do you think Kyoko-chan smells like haha
>>
>>60384744
good god she makes me so horny
>>
>>60384768

I don't really know the stats. It's all up to you, however. It certainly won't count against you when applying for a PhD, that you have worked in the industry.
>>
>>60384774
pardon my newfag question, but why does she wear this mask?
>>
>>60384782
You don't need to read/lex/parse with something as simple as a toy Scheme. First implementation you can just build the lists as you read chars.
>>
>>60384881
I know but well, i want to try to implement my own language no matter how retarded, just as learning practice and i kinda feel i need lexer for that.
Ill go through >>60384746
as well
>>
File: 1494352305814.jpg (29KB, 293x339px) Image search: [Google]
1494352305814.jpg
29KB, 293x339px
>Too stupid for python
Should I just kill myself?
>>
>>60385014
python is far from being the easiest programming language to learn.
>>
>>60385014
if that's your first language, you're too stupid for everything right now. just keep at it.

i think that those of us that started when we were <10yr old had it easier not because we had an head start, but because we didn't expect/want to succeed right away. It honestly took me more than one year since I started getting interested with programming and being able to do an hello world (!!!!! I'm not joking!). If I had to start now, I'd give up after a couple of days of not being able to do that. Sure, I'm not 10, I would probably be able to type an hello world, but at the same time my expectation is not to type hello world, I would want to do NLP on a novel or scrape a website right away.
>>
the fuck, haskell? pandoc goes OOM at less than 2GB of ram... and I have 32GB available.
>>
>>60385064
Was your program running for 32 seconds or longer?
>>
>>60385035
Huh? Always found it the easiest to learn and use? What would (You) say is the easiest to learn?
>>
>>60385095
scheme, scratch, basic, lua
>>
File: 1483702618333.png (822KB, 438x480px) Image search: [Google]
1483702618333.png
822KB, 438x480px
>>60385127
>scratch
This.
>>
>>60385127
Do people still learn BASIC?
>>
>>60385198
some still do
https://twitter.com/ID_AA_Carmack/status/569658695832829952
>>
>>60385242
well i applaud teaching kids, not so sure about basic damn
>>
>>60384378
>pays a years middleclass income for a year of education
>get's jewd on the books as well
Stay classy murica
>>
>>60385095
C
Not even memeing
>>
Could you please help me out.
How do I create a loop in C++ that constantly checks for a press of a certain button?
I need to make a program that starts a loop when the Y is pressed and ends by pressing N without killing the program.
By googling I have only found getch and kbhit, both won't do the thing for me (or I'm severly stupid to make good use of them). Because getch requires push of a button and if i put it at the end of the body of a loop it will only go through once and will stop untill I press another button. Kbhit starts when I press any button, not a definite one.
Thanks in advance.
>>
>>60383788
I'm making my own virtual CPU architecture with its own instruction set and emulator
Shots pretty fun
>>
>>60385382
>memeing
>>>/v/
>>
File: 1492128111683.jpg (1MB, 2000x2800px) Image search: [Google]
1492128111683.jpg
1MB, 2000x2800px
>>60383788
Trying to average 2 integers in C!
>>
>>60385450
float average (T) (T x, T y)
{
return (x+y)/2.0;
}
>>
>>60385523
That's not C.
>>
>>60385411
>>>60385382 (You) #
>>memeing
>>>>/v/
>>/lgbt/
>>
>>60385408
This is what I'm planning on doing once the exams are over. What lang?
>>
>>60385586
Java
>>
>>60385450
What's hard with it?
>>
Cant imagine not using a language with templates.
Dont know how cniles do it desu.
>>
Write a function that determines the number of dimensions of an array

dim("abcdef") == 2 //char[]
dim(["abc", "sldci"]) == 2 //char[][]
dim([[12, 11], [1]]) == 2 //int[][]
dim('z') = 1 //char[]
>>
File: 1494332105752.jpg (733KB, 3702x2198px) Image search: [Google]
1494332105752.jpg
733KB, 3702x2198px
>>60385688
>>
>>60385586
C, this >>60385591 Java guy is an impostor, or maybe someone making something similar

My CPU has 8 bit instructions, its RISC inspired, has 256 bytes of RAM, with 16 general purpose registers. I'm planning on keeping the instruction set very small so currently it has only 16 instructions. I'm using conditional jumps for looping.
>>
>>60385450
Please stop posting this stale meme. It's already over.
>>
>>60385694
>char[] is two dimensional
>'z' is one dimesional
assuming this is meant to be C/C++, wouldnt they be 1 and 0 dimensions respectively? the first is a single array, the second is a character literal
>>
>>60385704
What sort of terrible language doesn't allow adding numbers of different types?

(println
(+ 1 1)
(+ 1 1.0)
(+ 1 1N)
(+ 1.0 1)
(+ 1.0 1.0)
(+ 1.0 1N)
(+ 1N 1)
(+ 1N 1.0)
(+ 1N 1N))


2 2.0 2N 2.0 2.0 2.0 2N 2.0 2N
>>
>>60385795
Rust and Ada

So 12i8+ 16f32 would not compile, unless you use generics
Your language does the same but it's nice enough to do it silently for you. :^)
>>
>>60385783
nothing is zero dimensional
>>
>>60385795
ocaml

>>60385820
dim([])
>>
>>60385836
>([])
[] is nothing
>>
>>60385807
>:^)
>>>/v/
>>
>>60385885
>>>/trash/
>>
>>60385694
(define (dim a)
(if (cons? a)
(+ 1 (dim (car a)))
0))
>>
>>60385694
Axiom array : Type -> nat -> Type.

Inductive list (T : Type) :=
| Empty
| Cons : T -> list T -> list T.
Arguments Cons {_} _ _.

Fixpoint multi_array (T : Type) (dims : list nat) : Type :=
match dims with
| Empty _ => T
| Cons dim dims => array (multi_array T dims) dim
end.

Fixpoint length (T : Type) (l : list T) : nat :=
match l with
| Empty _ => O
| Cons _ l => S (length T l)
end.
Arguments length {_} _.

Definition dimension_number :
forall (T : Type) (dims : list nat), multi_array T dims -> nat :=
fun _ dims _ => length dims.
Arguments dimension_number {_ _} _.
>>
>>60385807
>generics
What is a "Generic"?
>>
>>60385948
https://en.wikipedia.org/wiki/Generic_programming
>>
>>60385967
Sorry, I don't visit CIA websites. Could you explain it yourself?
>>
>>60385694
heh
enum dimensions(T : T[]) = 1 + dimensions!T; enum dimensions(T) = 0;
>>
>>60385991
Its C# and java's inferior templates
>>
File: 1485129506235.png (41KB, 315x259px) Image search: [Google]
1485129506235.png
41KB, 315x259px
>>60385946
What is the difference between Set and Type in Coq?
>>
>>60386043
Dunno.
>>
>>60385946

I'm genuinely in awe of people who can write Coq. I'm pretty good with a lot of languages including C and Erlang. And "developers" often comment that those are hard languages, and I say "no, coq is a hard language, everything else is easy.

I spent quite a bit of time reading one of the exercise books and gave up on ever doing anything with it.
>>
>>60386103
>Cock is hard
Who knew
>>
>>60386126
Fucking lol. Thank you anon, I didn't see it.
>>
>>60386103
>>60386043
What does Coq stand for? Code of queers?
>>
>>60386103
Most exercise books I've seen assume some knowledge of dependent types. So you really should start out with something like Idris.
>>
>>60386191
It's a pun. It's about Calculus of Construction, which was made by Thierry Coquant.
>>
>>60386195
Not him, but will idris take as much as time as C? I mean C is a small language to learn how about idris?
>>
>>60386191
>>60386203
And I forgot coq is rooster in French.

French people love puns, because French language is the only pun language in world (maybe Japanese too).
>>
>>60386195

Thanks. I'll look into it.

>>60386191

It had predecessor named from French animals, and now it's chicken apparently.
>>
>>60385807

The language doing things for me is sort of the point of it. It't not something to be ashamed of.
>>
>>60386212
Assuming you know something Haskell-like it shouldn't take a long time to learn.
>>
File: tlafizz.png (17KB, 716x391px) Image search: [Google]
tlafizz.png
17KB, 716x391px
>>60386103

Also TLA+ does interesting proofs.
>>
I need some project to put on my CV language really doesnt matter as long as its not damn web
>>
>>60386245

It can cause subtle bugs and isn't necessary. Generally you don't intend to add two numbers of different types together.

The syntax ada uses to solve this is neat too.
>>
Reminder that the composition of two measurable functions is measurable.
>>
>>60386714
>>>/sci/
>>
File: 1459583273725.jpg (55KB, 245x282px) Image search: [Google]
1459583273725.jpg
55KB, 245x282px
I'm sold on Rust. Talk me out of it, with good arguments.
>>
>>60386799
Gain of safety at loss of productivity. Programs that are trivial to write in C++/C can be more painful to write in Rust.
>>
>>60386827
>Rust
>more painful than C[++]
Jesus Christ, how horrifying.
>>
>>60386799
Not many arguments remain once you take out the loss of productivity and slow compile time.

These are the two things that are holding back Rust. I don't get it though, Rust is not trying to replace C or C++. I think it just wants to be a faster Ada
>>
>>60386872
>more painful than C[++]
Only if you're severely disabled.
>>
>>60386799
it unironically still doesnt have proper strings
its borrow checker makes its core design naive and narrow minded.
it already has as ugly syntax as sepples

tldr a meme language
>>
>>60386913
>meme
>>>/v/
>>
idea guy here
A language that can be used in daily life as well as compiled by a machine
>>
>>60386942
Go on, finish your sentence
>>
Anyone program in R understand the syntax for regressing variables/predictors

Fitting a classification tree:
> tree.carseats=tree(High~.-Sales,Carseats)
>High~.-Sales
What is the ".Sales" doing exactly usally in linear regression you would do y~a1+a2.. for example
>>
>>60385384
You could read the /dev/input and get it this way or you could use cin.get()
The last one requires enter though
>>
>>60385897
>using lists as arrays
Disgusting.
>>
File: 1493923045045.gif (2MB, 695x392px) Image search: [Google]
1493923045045.gif
2MB, 695x392px
Do you consider it a good code? It looks like something I would write in my "image processing" e.g. "hack things together until it works" class.
>>
>>60387007
It must be in C.
It must be in the Linux kernel coding style.
It must have been written by me.
>>
>>60387007
ops https://github.com/NewEraCracker/LOIC/tree/master/src
>>
>>60387007
bugfree and readable and efficient and properly documented

>>60387025
Don't listen to him, he's not employed
>>
>>60387026
>LOIC
>>>/trash/
>>
>>60387032
How on earth does somebody's employment status have an effect on the quality of the code they right?
You could employ me to be a chef, but that doesn't mean that'll make me good at cooking.
>>
>>60387054
Unemployed people are unemployed for a reason
>>
>>60385384
I can't paste my code for some reason,
so I try this:
https://pastebin.com/3bKPndTi
>>
>>60386911
C++ can be really comfy, use C with some nice C++ features for maximum lazy. Vectors, strings and std::algorithm and you can be productive. No need to dive into template hell or whatever...
>>
>>60385688
I've used macros for similar stuff.
>>
>>60387093
>with some nice features
>some features
>some
>>
>>60387112
What is it that you don't understand?
I prefer to write C but for fast and dirty I'd much rather not implement strings, concatenation, grow-able arrays or whatever might come in handy. Much better just to use C++ stdlib
>>
>>60387093
>C++ can be really comfy
Only if you're barely sentient.
>>
>>60387146
Do you like C?
>>
>>60387112

Yes, some. C++'s features are opt-in.
>>
File: 16730488.png (83KB, 866x960px) Image search: [Google]
16730488.png
83KB, 866x960px
>>60387139
>>60387093
>>60386911
>>
>>60387163
Not particularly. It's certainly better than sepples, though.
>>
>>60387208
Whats preventing you from writing C++ with C style and only using handy features in stdlib? C++ is huge language and noone is forcing you to use all of it, just use subset
>>
>>60387093
C++ is the most comfy language for me. I even have an inheritable GC class for where I don't feel like doing ref counting analysis.
>>
>>60387220
>Whats preventing you from writing C++ with C style
Not having shit taste in languages.
>just use subset
C is a subset of sepples.
>>
>>60387242
Mind sharing code for it or some resources? I'd very much like to know how to implement gc
>>60387252
>C is a subset of sepples.
impying set has only one subset
>>
>>60387252
>C is a subset of sepples.
No it's not, idiot.
>>
>>60387171
Rust faggots have created an impression that C++ is too big to be useful whereas in reality every standard just makes the features more orthogonal.
>>
>>60387220

This.
C with classes is a meme, C with stdlib + templates is far superior.
>>
>>60387276
You just said "subset", so I guess I'll use the least retarded one.
>>60387281
It is. C is a subset of every language.
>>
>>60387326

> C is a subset of every language.
This is what C zealots actually believe
>>
>>60387252
> C is a subset of sepples.
Not anymore.
They have diverged quite some time ago now.
>>
>>60387283
It is though
>>
>>60387334
I don't think someone who said he doesn't like C can be considered a "C zealot".
>>60387337
"C is a subset of every language" implies "C is a subset of sepples". This is true at any time.
>>
>>60387326
I'm pretty sure you have no fucking idea what "subset" actually means.
>>
>>60387393
I'm talking about sets from set theory.
>>
c vs c++?
>>
>>60387409
Yes, so am I.
>>
>>60387352
>It is though
Only if you're incompetent.

C++ features just make it easier to use, they aren't necessary to understand C++. If you can write something in C, you can use C++ right away. There's only 5 things you really need to learn:

- RAII
- How virtual functions work
- How to use and create templated classes
- How the template library/containers work
- Rule of 3/Rule of 5 (this is what separates the boys from the men)

If you can understand these 5 concepts you can consider yourself an intermediate C++ programmer.
>>
>>60387424
What's the problem then?
>>
>>60387431
You're blatantly misusing the term.
>>
>>60387433
Nope. I despise that kind of behavior.
>>
>>60387409

int main() {
int new;
}

This program belongs to the set of valid C programs.
This program does not belong to the set of valid C++ programs.

This the set of valid C programs is not a subset of the set of valid C++ programs.
>>
>>60387442
C is the empty set. Therefore it is a subset of sepples.
>>
>>60387427

>- Rule of 3/Rule of 5 (this is what separates the boys from the men)

>tfw still to dumb to understand move semantics and the difference between copy ctors/copy assignment
>>
>>60387093
stb.h is enough to make up for the lacking standard library of C. You get vectors and all that jazz, all in C.
>>
>>60387477
Really? I really should have heard of that sooner...
>>60387463
for move ctor just use A(A&& o) and for copy just what u usually do
>>
Reading the new Rust manual. It's really easy to understand even for a brainlet like me. When I tried to learn using the previous manual a while ago I gave up in a couple of hours, but this is a page turner
>>
>>60387528
try Rust essential
>>
>>60387276
>Mind sharing code for it or some resources? I'd very much like to know how to implement gc

I don't know about blog posts but I used Knuth volume I's very first "naive" algorithm, which is mark and sweep.

Basically create a GC class like this:

struct gc {
gc *next;
bool mark;
}


Note you can combine mark and next into a single memory word because in all modern hardware pointers have to be word aligned and you can use the LSB of the pointer. I'm not doing that here because I want it to fit in one post.

create a gc_new function and define a gc_list:

gc *gc_list = nullptr;

template<class T, class... Args>
T* gc_new(Args&&... args) {
T* n = new T(std::forward<Args>(args)...);
n->next = gc_list;
gc_list = n;
return n;
}


Then, create a gc_collect() function that:

1. Unmarks all nodes
2. Marks all nodes that are reachable, starting with a set of reachable nodes and then recursively calling all the nodes that point to them.
3. Scan across gc_list, deleting any unmarked gc. Inheritance will take care of calling the correct delete function.

You can even use this to turn container classes into garbage collected ones:

struct gc_string : gc, std::string {
template<class ...Args>
gc_string(Args&&... args) : std::string(std::forward<Args>(args)...) {
}
};


The only part you really have to think about is maintaining the basis of nodes you want to keep, which is also pretty simple in most cases (e.g active GUI windows for example).
>>
>>60387556

Thanks alot! Im gonna try and implement my own now
>>
>>60387463
You just have to understand the difference between lvalues and rvalues.

lvalues are anything that can be assumed to be assigned to something on the left hand side of an assignment, i.e named variables.

rvalues are like the values on the right hand side of the assignment.

Before move semantics this was all implicit in the language. After it, you can coerce a lvalue into looking like an rvalue by using std::move() (for example) so you can treat it like you treat something that would be unnamed (and thus you can take ownership of its values, for example a heap allocated piece of memory you'd rather not copy but just assign to a pointer).

I guess the toughest part is understanding the difference between std::move vs std::forward.
>>
>>60387477
>>60387502
libowfat is nice too. It is my go-to library when doing anything serious in plain C.
>>
>tfw no gf to compute digits of sqrt(3) with
>>
>>60387007
>>60387026
>Internet vigilante. Contributing to an open source world, fighting censorship and trolling the trolls since '09.

Even if you are being ironic, you are fucking cancer
>>
>>60387540
>Rust essential
but i'm already reading The Rust Programming Language Second Edition
>>
>>60387026
even by C# standards it's pretty gross
>>
File: inthetrashnow.jpg (27KB, 948x711px) Image search: [Google]
inthetrashnow.jpg
27KB, 948x711px
>>60387556
>tfw you left gc till last and couldn't find a good way of collecting together gc roots without rewriting your interpreter stack and binding code

Somebody kill me.
>>
>>60387085
Thank you very much.
I am newbie so it is hard for me to understand some of your code.
I tried asking for help elsewhere and they suggested using multithreading. I'm certain I'm doing everything incorrectly. Could you take a look.
https://pastebin.com/Y9V0ASdt
>>
>>60387701
Are you writing a scheme interpreter?

>>60387590
Any time anon
>>
File: 1494175402057.jpg (17KB, 327x299px) Image search: [Google]
1494175402057.jpg
17KB, 327x299px
Rewriting C in Node.js.
>>
>>60387804
I'm sorry for you, anon.
>>
>>60387556
why not std::shared_ptr and std::uniqe_ptr?
>>
"Some familiarity with the operations of web servers, browsers, and HTML is assumed in this chapter"
But where do i learn all those things? I wanna make basic stuff in python that access and interact with webpages, bots, etc. Google only brings up generic stuff like tutorials that teach you how to create a webpage but i'm not really interested in that
>>
>>60387856

std::shared_ptr fails to collect garbage if there are cyclic references.
>>
>>60387940
Not programming.
>>>/g/wdg/
>>
Why the FUCK is Fourch*n's piece of shit bot blocking me from posting code?
>>
>>60387780
Me? no. In my case this is a custom c-like langauge. Since I initially was going for a ref-counted language I just had a simple pointer with a refcount to point to objects (within the value class of the stack).

Once I added lists however I bumped into the probably-should-have-a-gc-because-of-cyclic-references issue. However its not too straightforward ATM since I need to make sure both external refs and refs in the interpreter stack(incl globals) and also refs in lists are handled correctly.

Doesn't help too much that both internal and external refs use the same value class either. It's no use doing a GC collection using just the current stack + globals since I would miss external references.

Prob need to rethink and simplify somewhere I guess...
>>
>>60387856
• triggered predictably in the middle of code flow. This sounds good but it also has cons:
•• goes off in the middle of the operations rather than as a batch process while you're waiting on I/O
•• can recurse
• it's not easy and dynamic : if you make loops, you're in trouble, so you have to be careful
• probably other stuff
>>
>>60387997
>> https://www.4chan.org/feedback <<

pretty sure it's cloudflare's attack detectors eagerly blocking anything that looks like an sql injection

something might be under attack or something, and most websites probably don't have users posting code
>>
>>60388018
>I/O
What if I don't use it?
>>
>>60387556
How do you read the pointers that a node has on other nodes to mark them ? I'm sure there are many solutions but you don't mention any afaict...
>>
RUST RUST RUST RUST RUST
RUST RUST RUST RUST RUST
RUST RUST RUST RUST RUST
RUST RUST RUST RUST RUST
DID I MENTION RUST RUST RUST
EVERYONE, RUST IS HAPPENING
RUST RUST RUST

RUST, SO HOT RIGHT NOW. RUST.
>>
File: 1494715348049.png (72KB, 300x300px) Image search: [Google]
1494715348049.png
72KB, 300x300px
>>60388104
I started reading the Rust book. It's actually pretty alright, desu
>>
>>60388102
You do it by creating a virtual function in every class that inherits gc and mark every non-null pointer it needs as part of its members.
>>
Please use Rust.
>>
>>60388134
>I started reading the Rust manifesto
FTFY
>>
>>60388143
I'll think about it, once I get used to it
>>
File: 1475551712845.png (431KB, 611x607px) Image search: [Google]
1475551712845.png
431KB, 611x607px
Is C a Rust dialect?
>>
>>60388153
>>>/pol/
>>
>>60388104
'CAUSE MY SEX JUNK

IS SO, OH OH OH

IT'S NOT EITHER, OR OR OR
>>
>>60388136
Very clever, ty anon.
>>
>>60384344
It;s seems a little inconsistent, isnt it? In the case of char[][] (String[]) you want us to traverse all of the chars but inte the case of int[][] you only want us to look at the int[]. Imo
assert([[234,12], [301,121,12], [322]].without(12) == [[234], [301,121], [322]]);
>>
>>60388171
>>>/r/abbit
>>
>>60388205
>>>/trash/
>>
all these meme languages

not a single one that makes C++ obsolete

how can brainlets even compete
>>
>>60387967
Have you even read my post or you just rushed to write that as soon as you saw "HTML"
>>
>>60388171
>>>/lgbt/
>>
>>60388171
it is rust itself that should fuck off to /pol/
>>
File: Screenshot_2017-05-15_00-36-24.png (144KB, 1920x1055px) Image search: [Google]
Screenshot_2017-05-15_00-36-24.png
144KB, 1920x1055px
>>60388187
D sucks
>>
>>60388252
>>>/trash/
>>60388289
You can accompany
>>
>>60388300
this doesnt pass all the test cases, specifically
assert(["siwwo", "lkaiwmn", "diw"].without("iw") == ["swo", "lkamn" "d"]);
>>
>go back in time and teach alonzo church idris
>go back in time and teach alan turing java
Choose wisely
>>
>>60388335
Oh missed that

Making me think. It seems he wants to work with both (T[] x, T y) and (T[][]x, T[] y).
>>
>>60388380
That's exactly the problem I'm pointing out.
if
assert(["siwwo", "lkaiwmn", "diw"].without("iw") == ["swo", "lkamn" "d"]);

then
assert([[234,12], [301,121,12], [322]].without(12) == [[234], [301,121], [322]]);

but OP only wants us to recursively work on string arrays for some reason
>>
>>60388371
>go back in time and teach alonzo church idris
This, but calculus of constructions instead of idris.
>>60388410
That won't be enough. You need to take out at least 3 more ""people"" to make a difference.
>>
>>60388408
Probably that's the catch of the problem
>>
What if I actually want ['a', 'b', 'c'] instead of just "abc"? (>>60388300)
Fucking C just fuck off my life
https://dpaste.dzfl.pl/f86ac4efa8f7
>>
>>60388565

char[] foo = {'a', 'b', 'c'}
>>
>>60388607
Wait what?
Isn't the below code is the correct way?
char[] foo= {'a','b,','c','\0'}
>>
>>60388371
>go back in time and teach alan turing java
this
>>
File: IMG_1694.jpg (743KB, 3000x2000px) Image search: [Google]
IMG_1694.jpg
743KB, 3000x2000px
PLEASE RATE THIS BOOK

(((no bully)))
>>
>>60388656

depends if you're declaring a "string" or literally a char array
>>
>>60388672
I literally want a char array NOT fucking String
>>
>>60388656
you only need the '\0' if you want to be able to treat it like a C string
>>
>>60388681

And that's what this is.
char foo[] = {'a', 'b', 'c'};
>>
File: 1488434921306.jpg (54KB, 444x399px) Image search: [Google]
1488434921306.jpg
54KB, 444x399px
>>60388670
>(((Global edition)))
Fuck off, globalist cuck
>>
>>60388716
>>>/lgbt/
>>
File: textbaseduserinterface.webm (1MB, 1920x1080px) Image search: [Google]
textbaseduserinterface.webm
1MB, 1920x1080px
I am finishing up with my Text-based User Interface library for Windows.
I used C# and the whole goal of the project was to only use what the "vanillia" .NET core offered, so any extern method was banned from useage.

It was quite a pain because how Windows Works with the cmd, but I could overcome it.

The programs that are made with this lib are also capable of launching from the terminal. Also you can use integers and ratios to determine the size and position of the controls so it is quite flexible.

Available controls so far:
Labels, Buttons, Textboxes, Panels, Statusbars
>>
>>60388744
>>>/trash/
>>
>>60388535
im not writing a """generic""" function that treats types differently, that's moronic
>>
>>60388803
>autistic screeching
>>
>>60388803
>generic
What is a "Generic"?
>>
>>60388803
>writing a generic function at all
>>
>>60389040

C zealot detected.
>>
>>60389101
when do you even use generic function? when you're literally just storing things in a data structure? woooooooooooooooow /s
>>
>>60389232

sum_int(int foo[]);
sum_long(long foo[]);
sum_float(float foo[]);
sum_double(double foo[]);

cfags will defend this
>>
>>60389271
yes because there are different algorithms for summing floats vs integers like pair-wise summation and kahan summation, and usually you're doing more than just summing an array, you may want to put other things in the loop
>>
>>60389299

Then you need template specialisation or function overloading instead.
>>
/!\ A L E R T /!\

New thread

>>60389332
>>60389332 >>60389332
>>60389332 >>60389332 >>60389332
>>60389332 >>60389332
>>60389332

/!\ A L E R T /!\
>>
>>60389322
that's my point, the use case for generics is so weak, you can use generics for a basic list or hashmap or something but past that generics aren't all that useful
>>
>>60388912
Something unnecessary in any language worth using (i.e. one with dynamic types)
>>
>>60389357

I too love rewriting trivial containers every time I want to change the type of the data it containes
>>
>>60389394
No need if your language is dynamically typed, like it should be.
>>
>>60389271
BLOWN THE FUCK OUT
>>
>>60389394
99% of the time you should use structs and arrays not fucking linked lists. even when structs and arrays aren't sufficient you'll be using custom data structures not just trivial containers
>>
>>60389412

I like programming languages that are fast and make errors easy to find.
>>
>>60389417
see >>60389299

also integer overflow

kill yourself
>>
>>60388748
i want to say this is nice but
>windows
>c#
why do you even put so much effort into this shit platform and shit language?
>>
>>60389449
Solve this, C tard>>60383806
>>
>>60389559
>solve this in one (ONE) function
for what purpose

you should use strings like that in the first place
>>
>>60389587
>should
shouldn't
>>
>>60389587
>for what purpose
For cucking C tards of course
>>
>>60389638
try making some real software which actually matters in the real world outside of your mental masturbation
>>
>>60389666
>Are you upset now?
Brainlet C tard
>>
>>60389299
you should optimize when you need to. generic procedures reduce development time significantly

for example

T sum(Array<T> array)
{
T s;

for T t in array
{
s += t;
}

return t;
}


will sum an array of any type that implement the += operator. if it's too slow for a specific type, then you overload this procedure with a specific one for the said type.
>>
New thread:

>>60389695
>>60389695
>>60389695
>>
>>60389704

>>60389332
Thread posts: 327
Thread images: 39


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