What are you working on, /g/?
Previous thread: >>51304261
oop is actually pretty cool
>>51307595
If your language doesn't have pointers
kill yourself
>>51307609
you're*
>>51307609
If your language requires header files, kill yourself.
>>51307616
It doesn't
>>51307609
Mine has pointers. :^)
>>51307603
this tbh fam
what is the advantage of a treeset over an array list. except for the treeset sorting the objects
>>51307649
You have more time to think about how to improve your data structures while your code is running
nothing, because my head is damaged. Some time ago I finished my first transponder-prototype for a time-keeping appliance for motocross
>>51307662
hmm. care to explain.
right now i have to program a system for a bar so that the barman can easily add orders to a table and pay orders. (college assignment)
in this use-case, is it still useful
>>51307687
arrays gotta go fast
>>51307687
Data structures aren't objectively better than other structures, they have their areas where they're better and areas where they aren't.
For example, a tree is better for large amounts of sorted data and searching for specific data where an array is better for looping through sorted/unsorted data.
>>51307716
>Data structures aren't objectively better than other structures
>Data structures aren't objectively better than other structures
>Data structures aren't objectively better than other structures
>Data structures aren't objectively better than other structures
>Data structures aren't objectively better than other structures
>>51307687
BST
>>51307730
You forgot
>they have their areas where they're better and areas where they aren't.
>>51307609
>>51307616
Go has pointers and doesn't have header files. do I win?
>>51307826
It's just a meme
>>51307716
>Data structures aren't objectively better than other structures
What does this even mean?
>>51307716
A tree is a data structure you fucking dingaling
>>51307834
ALL DATA STRUCTURES ARE BORN EQUAL
#linkedlivesmatter
>>51307834
A tree isn't objectively better than a linked list.
A linked list isn't objectively better than an array.
They're used to fit the requirements of the current program.
What the fuck do you think it means?
>>51307845
What "other structures" are there?
A tree is a data structure
A linked list is a data structure
>>51307831
>lots of web/network services depend on Go software
>"It's just a meme"
/dpt/ - 2015
>>51307845
Linked lists are always shit.
Name one scenario where a linked list is optimal.
>>51307871
Insertion into large ordered structure
Because structure is ordered searching is faster too
>>51307850
>Queue
>Stack
>Hashmap
>[custom made structure to fit your data requirements]
Are you just pretending to be retarded at this point?
Go and Rust are the future. Start getting good at them or get left in the dust
>>51307881
Those are not "other structures"
Those are data structures
Did you mean to say "Certain data structures are not objectively better than other data structures?"
Back to English school kid
>>51307834
>>51307850
Not the same guy, but I believe he means:
[any given] data structures aren't objectively better than other [data] structures.
That is to say:for x in dataStructures[]{
for y in dataStructures[]{
dataStructures[x].objectiveValue = dataStructures[y].objectiveValue;
}
}
>>51307880
>Because structure is ordered searching is faster too
Can't binary search a linked list.
>>51307871
Sorted data that gets data inserted often (easy sorting since insertion is just changing two nodes) and needs to be looped through.
>>51307880
Tree
Vector of objects, vector of sorted indices
Vector of pointers to vectors
>>51307903
>>
>>51307905
We need to get rid of linked fucking lists
>>51307891
You're being fucking autistic. Data there was heavily implied with the term "other".
>>51307905
Insertion is slower in all of those
>>51307903
>Can't binary search a linked list.
Nobody wants to
>>51307901
>O(n^2)
Kill yourself
>>51307919
Autism is one of the tenets of being a /g/entooman
>>51307595
>What are you working on, /g/?
The official /dpt/ C toolkit. A general utility, state of art, library written by the community of /dpt/.
>>51307871
Real time systems. You don't want to have a few ms delay/pause because your vector is allocating/freeing/ when your plane is landing.
>>51307919
Absolutely wasn't. Your English is fucking garbage mate.
>>51307880
False. Even on garbage hardware vectors are much faster up to 500k elements.
>>51307905
>tree
Enjoy sorting that every second when new data gets added.
>>51307920
Searching can't be faster if you can't do the faster searches.
>>51307595
Reimplementing Wolfenstein 3D in Haskell.
>>51307938
Searching is faster than an unordered array
Faster doesn't imply fastest
Linked lists are the ideal solutions for OS buffer caches because of fast insertion and fast enough searching
>>51307934
>other
>as in something else of the same type
>if I have two int arrays and I have five others, I have seven int arrays (for god knows what reason)
Nah, you just have full blown autism.
Attempting to figure out how to use std::atomic<T*>.
So far I have one as a member of a class uninitialized.
Then I run the std::atomic::exchange() function
And then I get a Access Violation writing location 0x00000000.
>>51307949
>>other
>>as in something else of the same type
The type here being "structures".
>>51307956
No, the type being data structures (the original type).
Structure was just used as a short method of referring to it.
I'm new at GMP and have a question about big number arithmetic.while(a != b)
{
if(a > b)
a = a - b;
else
b = b - a;
}
cout << "The GCD is " << a << endl;
This works fine when running normal numbers, but when I run HUGE numbers (like 100 digits big) it just stops and doesn't go through them all. My question is does GMP have a way to quickly do this that I'm not aware of? I declared a and b asmpz_t a, band can add and subtract huge numbers fine. It's just looping loses me.
>>51307949
Methinks the person you're arguing with only supports static typing.
>>51307969
When you said "than other structures" the type "other" is referring to is "structures"
You don't get to make up new English rules
You should have said "than other data structures"
>>51307862
Just a tiny fraction compared to PHP :)
>>51307983
I genuinely think you have autism, you need to get yourself diagnosed by a doctor.
>>51307977
I vaguely remember something about no being able to use normal operations with mpz_t variables. Something about the GMP compare function.
>>51307983
To be fair, a data structure is a subtype of structure, but other subtypes of structure can't be objectively compared to data structures. If you parse the language correctly, you can unobfuscate implications and put that much together. This is a concept known to human beings as "common sense". To assume he's talking about structures that can't be compared to data structures when comparing them to data structures, is to assume he's trying to get you to throw an error, at which point, if you're right in that assumption, you gave him what he wants, whereas if you're mistaken, good job at bad parsing.
https://news.ycombinator.com/item?id=10539328
>In a golang conference, the presenter talking about youtube's vitess said: "If vitess servers are down, then youtube is down. That's how golang is crucial for youtube"
also, cloudflare uses Go. need I say more?
>>51308018
Human language is necessarily intricate and not resolvable to simple syntax rules.
>>51308018
Now this is real autism.
>>51308032
wow google uses their own product, how surprising
C:
http://codepad.org/DrRDjhId
Got right up to line 143 when I realized I designed my program wrong.
A gradebook holds an array of students and num_students. A student looks like this:struct student {
char name[MAXNAME + 1];
unsigned idno;
unsigned math;
unsigned reading;
unsigned science;
unsigned history;
unsigned computers;
};
I want to implement a function that allows me to choose a subject and print the top N students in that subject. That is, print_subject_top(3, gradebook, READING) prints the 3 students with the highest .reading grade.
However I realized this is quite difficult with my structure and that a subject enum with values like READING doesn't quite cut it for arbitrary subjects. Does anyone see a better way to implement this? Perhaps an array of grades instead, or some tricky macro?
>data structures
IF YOU DON'T USE COMPRESSED SPARSE MATRICES FOR LITERALLY EVERYTHING THEN YOU LITERALLY DON'T CARE ABOUT PERFORMANCE
>>51308067
unsigned subjects[NUM_SUBJECTS];
subject type becomes index
>>51308034
English is a living language. Currently, people all over the world are speaking it differently. In the ghetto, they speak it in a way that you *must* look for context clues and process syntax, as words mean nothing.
You are thus implying that English is not a human language, as you claim human language is not resolvable to simple syntax rules.
Meanwhile, you can only understand a select few people, whereas I can process the speech of the most and least educated anglophones simply by resolving language to syntax rules. Can you guess who has more survival potential?
>>51308087
but how much can you bench?
>>51308053
and yet people keep asking if google uses Go, or if Go is even used in critical systems
>>51308067
Codepad is acting weird.
http://pastie.org/private/y8zpg3muiu6cifvuwobi2g
the fuck is this shit
I'm like, 99% sure that my code has nothing wrong with it.
Especially since std::atomic has such shit documentation
>>51308101
That depends. We taking social engineering botnets into account? Cause my monkeysphere is full of people who hit the gym way too often to try to drown their depression in sore muscles.
>>51308034
Do you even lojban?
>>51308124
Should I just tell atomic<T*> to fuck off and just use shared_ptr<T>s?
I hear shared ptrs have atomicity
>>51308178
>If multiple threads of execution access the same shared_ptr without synchronization and any of those accesses uses a non-const member function of shared_ptr then a data race will occur;
>>51307845
An array is objectively better than a linked list.
>>51308087
>not resolvable to simple syntax
>NO SYNTAX WHATSOEVER?!?!?!??!?!?!?!?!?!?!?!?!?!?!?!?!?!??!?!?!?!?!?!?!?!?!?!?!?
>must write autistic reply
>>51308235
But that's wrong.
>>51308235
enjoy your no concept of lazy evaluation
>>51308235
Why?
>>51308249
You can't get any simpler syntax than English. It's the most mind numbing language on the planet.
>>51308235
it's faster to insert in the middle of a list
it's faster to delete from a list
it's MUCH faster to delete all references to an object instance in any intrusive list from that object's destructor, which is the main motivation for lists in high-performance stuff
>>51308295
please write a simple program that can understand what is being said in English 99.9% of the time while only knowing simple syntax rules
>>51307932
Is there a online repo?
TEПEPЬ ЭTO PУCCКИЙ ЧAT
MAКC PEПOCT
>>51308326
I don't write language parsers. I write games. R&D would take longer than this thread will live.
>>51308446
You can't write language parsers and you don't write games, at best you program them if not a small part of them.
Language parsers don't just rely on syntax rules, they need to be artificially intelligent and capable of learning.
>>51308371
no.
>use Visual Studio
>work on Web project on PC1
>solution builds without any errors
>use git to transfer the Web project to Laptop1
>over 30 errors, including missing NuGet packages
>everything is there, I manually checked
Any ideas guys ? The errors make no sense at all, I get errors at my Razorview, ViewBag etc.
>Want to make a large program of mine multi threaded
>Check tutorials
>Have it all done within 30 minutes
I love you Java!!!
>>51308717
Run tests. Your program is incorrect.
>>51308711
Tried clean + rebuild?
>>51308711
you might not have committed everything necessary
use github's VisualStudio.gitignore, and do a git add -A.
>>51308741
All of the threads are working with with separate structures and results. Anyway I checked the new stuff against previously known results and it's all good.
>>51308741
It's in Java, why would he need to test?
Of course it's broken
i have an array list where you have the length: the number of elements, and the capacity: the number of allocated slots. i have a operation trimCapacity(ArrayList a) which adjusts the capacity to the length. now, i want an operation that would raise the capacity to N. how would you name it ?
>>51308772
What's the difference between an array and an array list?
>>51308782
Arrays are fixed size arraylist isn't
Prob some other nerdy language specific differences too
>>51308772
rename trimCapacity to truncate and give it an additional, optional int n parameter.
If given, truncate to n, deleting elements if necessary, else resize to the number of allocated slots.
>>51308782
array list is an implementation of the abstract type list where the elements are stored in an array, it's what c++ calls a vector (which is wrong). other implementations are linked list, double linked list, ...
>>51308772
shrink
expand
>>51308742
Yes, I'm getting the same errors.
>>51308752
I pulled the same Web Project on my Computer1 and there it's working fine.
>>51308809
why is this wrong
are they stored contiguously
>>51307647
What the fuck? were the word filters rmoved?
desu senpai baka
>>51308825
same visual studio?
completely updated to latest version?
>including missing NuGet packages
have you tried opening the nuget window and clicking Restore?
>>51308833
because a vector is not a list but more like a tuple.
http://stackoverflow.com/a/758548
https://en.wikipedia.org/wiki/Vector_%28mathematics_and_physics%29
https://en.wikipedia.org/wiki/Tuple
>>51308859
vector in C is different to the mathematical definition
>>51308772
trimCapacity -> shrink_to_fit
resize
>>51308852
Yes everything is the same. Updated etc.
I've tried that and it did restore some things but again it says that I'm missing Microsoft.Compiler which is there (both in the NuGet package window and on my Laptop).
>>51308870
resize is problematic because i have an operation size(ArrayList a) that returns the memory size (in bytes) while length(ArrayList a) returns the size in elements.
>>51308886
>problematic
Triggered.
>>51308885
a quick idea, try creating the web project on laptop, then commit that project to git, and see if it compiles on your desktop...
if it does...well, I'd just manually copy and paste everything over...
>>51308772
Extend
>>51308124
Oh my god it's so hard to find an up-to-date compiler that doesn't have a broken std::atomics implementation
>>51308913
is extend relative or absolute ? extend(5) implies capacity + 5 or capacity = 5 ?
>>51308911
That I haven't tried but it is a good idea.
At least to find out what is causing the problem.
I'm procrastinating studying for my crypto class whilst learning Golang. Also reading interview prep.
>>51308989
>learning golang
how do i fill an array of semen
>>51309044
Open up your buttcheecks.
Messed up a screening interview question today, /g/.
The problem is:
There's a frog at one bank of a river that needs to get to the other side, which is X distance away. The frog can only jump D distance in a single bound. Every second, a leaf falls on the river. Given an array A where A[n] is the position a leaf falls at at the nth second, determine the second at which the frog is able to hop across the river. The algorithm's complexity has to be linear with the number of seconds in A.
Now, if it weren't for the runtime requirement, it would be pretty simple: at each second, add the new position to a sorted list of positions (least-first). Remove all positions from the list that are at or behind the frog's current position. Then, while there are positions that are within jumping distance of the frog's current position, set the frog's current position to the new position and remove the position from the list.
Problem is that the insertions are going to be O(log n) no matter what, and since n of them occur, the overall runtime will be O(n log n). I can't seem to find a way of solving this problem that doesn't involve sorting of the leaf positions to make the runtime linear.
Anyone have any ideas? Am I coming at this totally wrong?
>>51309056
Oh, I should have added: after the leaf-traversal part of each iteration, if the bank is within jumping distance of the frog, then the current second should be returned. And if all the seconds are accounted for and the frog still hasn't reached the bank, then an error should be returned.
java's method to raise the capacity of an array list to N is is ensureCapacity(N), what you guys think about this nomenclature ?
>>51309023
It takes maybe 30 minutes and then you can add it to your resume.
>>51309109
Verbose and ugly, like everything in Java.
>>51309115
Are you Indian by any chance? Only these smelly fucks would consider putting a language on their resume after a day of reading about it.
>>51309146
>Only these smelly fucks would consider putting a language on their resume after a day of reading about it.
ITT we've never applied for jobs
Most people here put languages on their resume before they've even started them
Get called in for an interview? Learn the language in the days before the interview
>>51309146
No, I've just done a few projects with Go and know how simple the language is.
>>51309152
>The reason fizzbuzz why exists: The post
>>51309167
If you can't do fizzbuzz after learning a language for 5 minutes, never mind a few days, I think it's time for a different hobby
>>51307935
>up to 500k elements.
>implying any number matters
>>51308859
. . .
>>51308809
>(which is wrong)
>not understanding cpu architectures
>>51309307
what ?
>>51309377
>he doesn't know what a vector is
>laughing SIMD and MIMD architectures
Since there's a UDL:
template <char ... str>
inline auto constexpr operator ""suffix();
is it technically now the case that ANYTHING is potentially valid C++, string escaping aside?
>>51309460
(I mention that UDL because it allows you to /statically/ interpret whatever you like, presumably allowing arbitrary return types)
>>51309452
wtf, c++ vector and simd vector are two different things.
http://en.cppreference.com/w/cpp/container/vector
>>51309056
> Every second, a leaf falls on the river. Given an array A where A[n] is the position a leaf falls at at the nth second, determine the second at which the frog is able to hop across the river. The algorithm's complexity has to be linear with the number of seconds in A.
> Anyone have any ideas? Am I coming at this totally wrong?
Do the leaves remain on the river indefinitely? If they only remain for a fixed amount of time, then a linear solution should be clear.
Otherwise ... it's possible that an algorithm which appears to be O(n^2) is actually O(m*n) where m is proportional to X/D.
Consider: find the first i where A[i]>=X-D. Clearly, the frog can't reach the other side before that i. Now the question is finding the least j where A[j]>=A[i]-D. And so on. Each of those steps is O(n), but the question is whether the number of steps is O(1).
>>51307716
Shit diagram. Just use vectors. Even the guy that invented the STL says so:
“Use vectors whenever you can. If you cannot use vectors, redesign your solution so that you can use vectors". -Alex Stepanov
any bounded set where the maximum and minimum values are known can be sorted in O(n) time.
;^)
>>51307932
>written by the community of /dpt/
m8
it's literally just you, and you said you wouldn't even post the source anywhere
>>51307932
>written by the community of /dpt/
>no repo
Sounds like shit already.
>>51308001
l2into english fgt
>>51308045
>I'm dumb as balls
>>51307932
You realize that not a single person will use your library because all of C programmers suffer from NIH syndrome and they'd rather reinvent the wheel on their own? Case in point: your code, you're doing something that's been done numerous times.
>>51308309
>faster to delete from a list
false
>lists in high-performance stuff
top cuk
>>51310081
Happiness is a journey, not a destination; happiness is to be found along the way not at the end of the road, for then the journey is over and it's too late. The time for happiness is today not tomorrow.
>>51310095
>sucking dick with such enthusiasm
>>51307886
go and rust are competitors. rust is superior anyway
>>51310179
>rust
>superior
he fell for the rc<>arc<>unwrap meme
>>51310205
are you serious? rust doesn't even do reference counting at runtime. you've either got it confused with swift, or are just trolling
>>51310205
>go
>superior
he fell for theif err != nil {
meme
What's the quickest way (in terms of processor time) to implement fizzbuzz?
I'm talking, maximum autism
bonus points for making it look pretty
>writing C code with ed without indenting
>run `indent mymain.c main.c`
>>51310231
can you even into ia32e m8?
>>51310223
I just cannot understand what Go is meant to be used for. Unless it's for an incredibly narrow use case of when you want better performance than something like C#, but want a more productive language than C/C++. And you don't mind that both those languages have incredibly large and mature library ecosystems, tool chains and labour pools and Go is relatively shit.
I find it hard to picture a large project that's going to turn out better in Go than one of the other options there.
>>51310262
Systems programming, m8!
>>51310231local t = {1, 2, "Buzz", 4, "Buzz", "Buzz", 7, 8, "Buzz", "Buzz", 11, "Buzz", 13, 14, "FizzBuzz", 16, 17, "Buzz", 19, "Buzz", "Buzz", 22, 23, "Buzz", "Buzz", 26, "Buzz", 28, 29, "FizzBuzz", 31, 32, "Buzz", 34, "Buzz", "Buzz", 37, 38, "Buzz", "Buzz", 41, "Buzz", 43, 44, "FizzBuzz", 46, 47, "Buzz", 49, "Buzz", "Buzz", 52, 53, "Buzz", "Buzz", 56, "Buzz", 58, 59, "FizzBuzz", 61, 62, "Buzz", 64, "Buzz", "Buzz", 67, 68, "Buzz", "Buzz", 71, "Buzz", 73, 74, "FizzBuzz", 76, 77, "Buzz", 79, "Buzz", "Buzz", 82, 83, "Buzz", "Buzz", 86, "Buzz", 88, 89, "FizzBuzz", 91, 92, "Buzz", 94, "Buzz", "Buzz", 97, 98, "Buzz", "Buzz"}
for i = 1, #t do
print(t[i])
end
>>51310231#include <iostream>
#include <cstdlib>
struct Matcher {
int multiple;
const int factor;
const char * const noise;
inline Matcher (int n, const char * s) : multiple (n), factor (n), noise (s) { }
inline void operator () (int n, bool &toSetIfMatched) {
if (n > multiple)
multiple += factor;
else if (n == multiple)
toSetIfMatched = true, std::cout << noise;
}
};
int
main (int ac, char **av)
{
int upTo = ac > 1 ? atoi (av[1]) : 100;
Matcher threes { 3, "Fizz" };
Matcher fives { 5, "Buzz" };
for (int n = 1; n <= upTo; ++n) {
bool matched = false;
threes (n, matched);
fives (n, matched);
if (!matched)
std::cout << n;
std::cout << '\n';
}
return EXIT_SUCCESS;
}
>>51310231
>what is haskell
>what is clojure
>what is meme language november 2015 edition
>>51310231for (uint i = 1; i < 101; puts(""),++i)
{
if (i%3==0)
{
printf("Fizz");
if (i%5==0)
goto buzz;
continue;
}
if (i%5==0)
{
buzz:
printf("Buzz");
continue;
}
printf("%u", i);
}
>>51310271
>garbage collected systems
k
>>51310278
I can't stop laughing
>>51310285
>std::cout
>performance
u for real mate?
>>51310288
>puts
>printf
>performance
into the trash it goes!
>>51310301
for some reason the universal meme symbol disappeared after I posted
>>51310315
those are implementation defined, you can't say anything about their performances by just looking at this code.
Daily reminder that Go is for keks.
>>51308741
it's actually really simple. he just needs synchronized(lock) blocks and he's golden. then for other things like with volatile and atomics he should read more about it before he thinks he's done
>>51310327
fuck me why can't I post these anymore?
>>51310205
Is garbage collection better?
>>51310336
>can't say anything about their performances by just looking at this code
confirmed amateur with no knowledge of performance programming
>>51310359
always
>>51310336
>those are implementation defined to be slow
ftfy
On my way to work. Hopefully I can shut my brain up a bit and get some work done.
>>51310401
>shut my brain up a bit
schizo?
>>51310336
wew lad
>>51310451
Feeling kinda meh about the job is all, not sure if I want to try getting a remote job or move someplace else. I've been living here since I was born and haven't lived anywhere else and would like to live somewhere outside of my region(southeast) for once.
>>51310231public final class FizzBuzz {
public static void main(final String[] args) {
System.out.print("1\n2\nfizz\n4\nbuzz\nfizz\n7\n8\nfizz\nbuzz\n11\nfizz\n13\n14\nfizzbuzz\n16\n17\nfizz\n19\nbuzz\nfizz\n22\n23\nfizz\nbuzz\n26\nfizz\n28\n29\nfizzbuzz\n31\n32\nfizz\n34\nbuzz\nfizz\n37\n38\nfizz\nbuzz\n41\nfizz\n43\n44\nfizzbuzz\n46\n47\nfizz\n49\nbuzz\nfizz\n52\n53\nfizz\nbuzz\n56\nfizz\n58\n59\nfizzbuzz\n61\n62\nfizz\n64\nbuzz\nfizz\n67\n68\nfizz\nbuzz\n71\nfizz\n73\n74\nfizzbuzz\n76\n77\nfizz\n79\nbuzz\nfizz\n82\n83\nfizz\nbuzz\n86\nfizz\n88\n89\nfizzbuzz\n91\n92\nfizz\n94\nbuzz\nfizz\n97\n98\nfizz\nbuzz\n");
}
}
>>51307611
>If you are language
Top Kik
>>51310653
kill you'reself tbh fam smh
Are pointers just numbers in C?
>>51310642
This, assuming the fizzbuzz is exactly 100.
I guess you could write code to generate a file and run that.
>>51310747
yes and no
void *v = 0;
int *i = v;
v += 1;
i += 1;
v != i
>>51310769
>java
>performance
TOP CUK!
>>51310747
> Are pointers just numbers in C?
Everything on a computer is just numbers.
>>51310790
>yes and no
>and
anon...
>>51310803
i have a coffee cup *on* my computer, is that a number too?
>>51310792
Well, that's pretty much the most performant way to do it in Java, at least.
I'm not saying that Java has good performance.
>>51310231
>maximum autism
does compile time function execution count?
>>51310921
bjarne pls go
>>51310943
>bjarne pls go
>what are lisp macros
k tard
>>51310954
>lisp
>performance
wew lad
>>51310251
>using ed
fuckin' lol
although the text file on the gnu site was pretty funny.
>>51307595
public static void main(String[] args) {
List<Integer> lista=new ArrayList<Integer>();//skapar lista
for(int i=0;i<1000;i++)
lista.add((int)(Math.random()*6)+1);//ger slumpvärden
System.out.println(antalSexor(lista));//Skriver ut räknat värde
}
public static int antalSexor(List l){//metod som räknar
int a=0;
for(int i=0;i<l.size();i++)
if(l.get(i).equals(6))
a++;
return a;
}
Could anybody help me change this program so that instead of using a list it uses a regular vector(in the method too) and so that the method counts all values less than three?
Please
>>51310817
No, but you are, and son.. Your number is up.
*tip*
How do I improve my code the fastest? How do you guys go about learning/improving?
>>51311048package skrap;
public class test {
public static void main(String[] args) {
int lista[] = new int[1000];
for(int i=0; i<lista.length; i++) {
lista[i] = (int) (Math.random()*6+1);
}
System.out.println(sixes(lista));
}
public static int sixes(int n[]) {
int a = 0;
for(int i:n) {
if(i == 6) {
a++;
}
}
return a;
}
}
quick and messy but should work, you could easily shorten it by yourself.
>>51311364
There is no "fast" way, you only need to put time and dedication to it, solve problems(even if it ends up messy). Learn from what you done, repeat problem and solve it again with another approach(more refined one).
what idiot thought it was a good idea to make C++ standard time durations such as std::chrono::milliseconds and std::chrono::seconds incompatible with each other?
yes i mad
>>51311412
>2015
>using c++ unironically
ishiggydiggy m8
>>51311412
whats the problem
>>51311393
How do you walk the fine line of getting help/doing things by yourself?
What's the correct way to express templated types in llvm via the C++ API (or IR I guess, I can translate)? That is,template<typename T>
T(*)(T, int)
for instance. Is the only option to make a tagged void*?
>>51311364
Use a systems programming language, like Go.
>>51311451
You get a code buddy(which is hard) or you just google the shit of the stuff and learn from it. Get an account at stackoverflow or somewhere else and post random questions or look at other peoples questions(that might be related to your problem). Good luck and have fun.
>>51311473
>You get a code buddy and you suck the knowledge out of his dick.
ftfy
>>51311445
im creating a class that uses an internal clock to keep track of some things and would like for said class to be constructed with a specific time delay passed into the constructor
problem is there is no "generic" time duration so i have to either force my users into always writing the time in milliseconds, create a shitload of constructors for every type, or use template shenanigans
>>51311528
or you could stop being a retard
>>51311549
quality post friend
>>51311528
git gut you shittertemplate <class R, class P>
void function(const std::chrono::duration<R, P> &duration)
{
// whatever
}
auto main(int, const char **)
{
function(100ms);
function(10s);
function(20ns);
return 0;
}
>>51311567
>meme
>tfw no python library is safe from my big C# dick
>>51311473
>not using this shit hole as your own personal code buddy
>>51311615
You again. How many times I need to tell you, we could have done that in C++ thousands of years ago
>>51311707
You said since 2005, it's been available in C# since 2006.
It's just highly exciting to me and I feel erect when I think about language interop.
>>51310217
WTF m8 ? Look it up fool, rust has an rc class that you can use when your allocation model implies shared ownership (and the arc class is atomic i. e. threadsafe) save yourself looking like a complete idiot, don't assume something is impossible, just look for someone who's already done it (the standard library ffs)
>>51311728
Thousands
Of
Years
Ago
How would we display the seating prices entered into display ticket prices.
>left side
the right side is just a seating chart of open seats. But when a seat is purchased then the purchased seat must be changed from '#' to '*'.
Any help is appreciated
>>51307595
>tfw learning java to become the ultimate neckbeard programmer
And when I've made something I'll shitpost
>>51311843
I assume your seats are stored in a 2d array, yeah?
When the user purchases a seat, check if it's already sold and if not change the array to either * or 1 depending on how you're storing the information in your array
seat[row][col] = 1;
>>51311934
Ya it is a 2d array.
We got it to display the rows and prices just now. Just have to make it look neat.
and thank you as well anon
>>51311902
>java
>ultimate neckbeard programmer
not even close
why?
>>51312561
because
I'm fairly new to programming and was wondering if for my first real project in C#, a calculator would be too challenging or not too challenging?
>>51312578
What do you mean a calculator? One without a GUI, then sure, you could knock that out real quick. If you want to use a GUI, I'd wait until later desu. You should learn to program before learning a library imo.
>>51312578
C# winforms programs have a drag & drop GUI builder.
>>51312659
>>51312632
Yeah, meant with visual studio, it's fairly simple to create a gui, not sure how complex it would need to be to actually program one, that's why I'm asking.
>>51312578
I think it's fine to start with a GUI.
The calculator will be as good as you can make it, and you'll start finding all these little issues and annoyances as you develop it.
Use Visual Studio and do a WinForm project.
Don't do WPF for now, as it will just confuse the shit out of you.
>>51312729
it's a waste of time if you're new to programming
learn
actual
programming
first
>>51312806
Such as? I'm pretty sure everyone defines that differently, what would you say actual programming is?
>>51312806
But doing a calculator with a GUI, rather than just a command line app, helps you build more skills.
It also gives the user more visual feedback on their inputs, outputs, and actions.
The big thing is that it's more interesting and fun, which can promote actually learning the stuff and seeing it through.
trying to install a crosscompiler mingw32 I screwed everything. Now I cant' even compile the most simple c file. I should have never used "sudo make install" with the default install path.
Is there something like "make uninstall"? I cant' believe I have to install linux all over again.
>>51312856
>he fell for the linux meme
>>51312856
Just force install the package to have it override the files.
On Arch that would be:pacman -S --force mingw32
>>51312923
can i do that with apt-get?
>>51312856
what distro? what error messages do you get?
>I cant' believe I have to install linux all over again.
you don't, ever, need to do this. if you really do this... you are the problem.
>>51312941
Try:apt-get -o Dpkg::Options::="--force-overwrite" install mingw32
>>51312966
It's linux mint 64bit.
It seems the make install replaced files from /usr/include and usr/bin and now if I try compiling some c it uses the mingw-headers instead of i686.
>>51312975
Thanks. I'll try that.
>tfw your spaghetti function crashes the program
>>51313041
Use a debugger.
>>51313061
sudo apt-get purge tripfag
>>51313076
I'm a windowsfag, please use OneGet. Thanks.
>>51312966
>you don't, ever, need to do this. if you really do this... you are the problem.
there are plenty of situations when it's preferable to just create a new virtual disk and start anew.
>>51313094
why would you use a poor copy of any linux package manager?
>>51313124
>virtual
key word
>>51313124
learn how to use your package managers. even if you, say, removed your own kernel, you would be able to install it either from the running system (if you hadn't rebooted), or from a live system (livecd/usb, whatever)
remember: linux is not windows.
>>51313176
of course is not. Linux is for virtual machines.
>>51313198
This.
Windows for main OS, Linux as VM. Always.
>>51307886
Go in the streets, Rust in the sheets
>>51313214
if you play games, yeah
If you browse the internet and program, no windows necessary
>>51313230
>if you play games, yeah
Who doesn't? "Videogames are for manchildren!" is a tired old meme.
>>51313214
more like
>Linux for main OS
>Windows as VM for when you port your programs
>>51313230
Why would you never ever play a video game?
Linux performs fine in a VM. Vidya in a VM not so much.
>>51313284
Can I not play games on my computer without being labelled as one of those faggots? I don't have a problem with games, I just don't play any.
>>51307611
you're* = a faggot;
Go is a shit language and you should literally use ANYTHING else at all. Google cucks gtfo.
>m-muh concurrency
Use Elixir you faggot
>>51313486
>>>/lereddit/
I'm gonna try building a Little Man Computer
>>51313458
That's fine, I'm just saying that the denigration of it, as a hobby, is retarded.
"Oh, you read books? Manchild!"
"Oh, you play board games? Manchild!"
This shit has been dumb since the 1800s.
>>51313537
can't click your meme arrows help please
>>51313526
>Google cucks gtfo
do you program in C# or Java, or any derivative langs?
>>51313214
why in the fucking hell would you use windows non-ironically, other than to play games and test windows software? do you enjow masochism?
>>51313561
>Manchild
Women will call us this until they want a piece of the action. Then we're the oppressors.
>>51311843
>>51311934
>>51312046
Literally homework.
Even fucking remember seeing you with blackboard open.
>>51313076
kek
>>51313561
>>51313725
Tripfags confirmed to come from /r9k/
What is your excuse for not using the best language
>>51313813
It hasn't been invented yet
>>51313813
But I'm using C++ right now, anon.
>>51313813
I'm raising you the better alternative.
>>51313813
But I am.
>>51313813
Because the only language I know is shit-tier haskell
>>51313838
It was invented in 1972.
>>51313785
Nah, I'm not a robot. Took an r9k quiz once though. Relatively close to normie.
>>51313858
I guess in some sense C++ did start in 1972
>>51313813
because I like to, you know, actually do real work.
>>51313895
i'm lazily evaluating so hard right now
>>51313890
C++ = 1985, and is not C, OOPooper.
>>51313813
>>51307941
https://storify.com/realtalktech
read up
learn real programming well first.
the real reason people go to functional programming is there are insecure with the myriad of new concurrency data structures (semaphores, mutexes) that came with the advent of SMP.
this is juvenile. it's cowardly shit - you can't learn smp data structures? Afraid of locking? So let's just create a whole cookie cutter language to tank everything down the tubes?
son of a bitch.
and then, act like you were so brilliant all along because you memorized a syntax that isn't expressive for anything except math?
If you use FP, my recommendation to you is to see a psychologist. chances are, no one here can help you understand the primitive cognitive fallacies you're in denial about.
if you really deep down want to save face, don't publicly push FP. it's like a bunch of wierd freaks who still wear diapers. or furs.
grow up
>>51313913
In the meantime I'm running CERN and Wall Street.
>>51313854
this
>>51313947
>act like you were so brilliant all along because you memorized a syntax that isn't expressive for anything except math
>implying that anything else that math matters
i want to learn about viruses, trojans, general threads. how its done, any good source for this topic?
>>51313813
I solve real-world problems
>>51313987
infosec/reverse engineering threads
>>51313982
>>implying that (sic) anything else that math matters
https://storify.com/realtalktech/lessons-for-functional-programmers
if i have quantized digital data like the red crap, HOW IN THE FLYING FUCK do i get the original smooth signal (grey), in software?
fseek(fp, 0, SEEK_SET);
rewind(fp);
which one is better?
>>51314017
>fourier what
>>51314017
rounding
>>51314017
Inverse FFT?
>>51314028
rewind empties cache before jumping
>>51308407
>russians
>shitposting
YOU FELL FOR THE MEME YOU STEREOTYPIC PIECE OF SHIT.
>>51314035
>>51314043
how can i get a function that represents the curve between t[n] and t[n + 1]?
>>51314163
https://en.wikipedia.org/wiki/Fourier_transform
https://en.wikipedia.org/wiki/Fourier_inversion_theorem
(the latter does what you want)
>>51314045
So I should use rewind before jumping back to the current position upon exit?rewind(fp);
fseek(fp, current, SEEK_SET);
hey
where can i find PDF's for this:
IEEE Std 1003.1-2001
IEEE Std 1003.1b-1993 Realtime Extension
IEEE Std 1003.1c-1995 Threads
IEEE Std 1003.1d-1999 Additional Realtime Extensions
IEEE Std 1003.1j-2000 Advanced Realtime Extensions
IEEE Std 1003.1q-2000 Tracing
>>51314192
www.g
>>51314177
this is some heavy stuff but it seems to be what i'm looking for
>In mathematics, the Fourier inversion theorem says that for many types of functions it is possible to recover a function from its Fourier transform. Intuitively it may be viewed as the statement that if we know all frequency and phase information about a wave then we may reconstruct the original wave precisely.
how do i get the fourier transform (frequency and phase information?) out of the red data in >>51314017?
>>51314224
Not an answer. Already tried.
They're not accessible via Google.
Where are the PDF's.
>>51311412
or you know, just do it likevoid foo(chrono::nanoseconds);
foo(chrono::seconds(2));
foo(chrono::hours(5));
>>51314243
one second
>>51314255
l
>>51314006
This is one of the worst things I've ever seen
>>51314265
e
(elixir + rust + racket = modern toolset)
>>51314281
.co.in
>>51314192
>>51314249
https://www.google.com/search?q=IEEE+Std+1003.1+site%3Apubs.opengroup.org%2Fonlinepubs%2F
>>51314006
>readable to you doesn't necessarily mean readable to everyone else
I just had an argument with my friend about this.
He said that he prefers using bitmasks over using multiple booleans. I told him that the few bytes of memory he's saving aren't worth the readability that he's sacrificing.
What does /dpt/ think? Are bitmasks worth it when writing non-critical code?
>>51314266
Care to elaborate? You're not being very helpful when you just say throwaway things like:
- "Unintelligent"
- "Worst"
- "Incomprehensible"
You're a functional programmer. Time to get into the grit, the crustules, the granuals and tear into logic.
If you're really so pure, why aren't you a billionaire?
>>51314308
in high level languages they can be equally readable
>>51314319
his debt isn't lazily evaluated
>>51314300
/?q=poo+in+loo
>>51314308
So passing 10 booleans to a function is more readable to you?
>>51314337
if you use encapsulate them properly then yes
>>51314364
You're mad.
>>51314335
search "goo"
first result
google india
>domain name ends in .in
>>51314335
>https://www.youtube.com/watch?v=_peUxE_BKcU
>UNICEF India
>The song has been created by Shri (who holds stunning compositions like the theme for the movie 'Life of Pi' to his credit)
>>51313947
Your articles are kinda funny, can't lie.
>>51314407
https://www.google.co.uk/search?q=india+toilet
http://timesofindia.indiatimes.com/india/India-Inc-fails-to-touch-50-mark-on-PMs-toilet-target/articleshow/48152940.cms
NEW DELHI: Corporate India and public sector undertakings are likely to fail Narendra Modi government's ambitious plan to have toilet in each and every school. With the August 15 deadline fast approaching, HRD ministry has decided to take help of state governments and if need be get directly involved in construction of toilets.
A senior HRD official said, "Eleven big corporates, 67 public sector undertakings including banks had taken the responsibility of constructing toilets but barring few, most have not yet reached even 50% mark." He said many companies have told government that due to fear of Naxal violence toilets cannot be constructed. "But not all toilets fall in Naxal dominated areas. We have been let down," he said. The official also explained that though it expects corporate groups and PSUs to fulfill the obligation it is unlikely that it will happen.
>>51314308
I agree with you.
Properly named booleans(IsMaximized, IsPrime) are easier to read and work with.
fuck indians xD
>>51314442
Were you behind std::vector<bool>?
>>51314308int open(const char *path, int mode, int append, int cloexec, int creat, int directory, int dsync, int excl, int noctty, int nofollow, int nonblock, int rsync, int sync, int trunc, int tty_init)
>>51314555
It's so readable, it takes 5 times longer to read!
>>51314555
I hope you never get paid to write software, holy shit.
https://storify.com/realtalktech/startup-ceo-s-functional-programming-isn-t-bad-it-
Functional programming will ruin your startup.
>>51314555
this is the most retarded shit
All you retards saying to pass booleans instead of bitmasks, why isfunction(condition1, condition2, condition3)
any fucking different fromfunctions(CONDITION1 | CONDITION2 | CONDITION3)
enjoy passing 15 fucking variables you retard
>>51314633
Excuse me? I am currently employed by the Open Group. That was an excerpt from POSIX.2016 :^)
Why does the manpage for gets() tell me to never use it?
What are the alternatives?
>>51314728
It's prone to overflow, use fgets() instead and specify stdin as the stream
>>51314308const int flaga = 0x01
const int flagb = 0x02
const int flagc = 0x04
const int flagd = 0x08
const int flage = 0x10
What's confusing about that? All you do isflaga | flagb
I mean, if you name your variables right, it shouldn't matter.
>>51314636
FP FAGS ON SUICIDE WATCH
>>51314636
are those books any good?
>>51314308
I would use prefer using a "set" as an abstracted form of bitmask.
In a language like C where syntax is mainly symbolic and low-level, I don't see raw bitmask manipulation as anything one should find more "unreadable".
I keep aimlessly trying to learn programming. Either I focus too much on easy tasks and get bored or I focus on too hard tasks and look up answers. Should I just take a huge break and/or kill myself? I know some part of me is a curious autist, but he won't show up...
>>51314946
Start with easy problems and then work your way up to bigger problems with the knowledge you've gained.
Unless you're telling me you're unable to retain information, in which case, kill yourself.
>>51314946
I was like you, then i started doing the codeeval problems one by one.
It's a really nice programming tutorial, desu.
>>51314958
I guess my follow then is either
1) How do I decide what problems to choose or how I will go about it?
or
2) Which type of rope can hold roughly 80 kgs?
>>51314976
Are there any other similar options/what is so good about it?
>>51314994
There's a lot of "coder ranking sites" i just picked that one because it's the most visible one.
The easy challenges they give you are similar to what you would get out of an introductory programming class.
So just pick a language you want to learn and grind through them.
If you want to get decent scores tho, always pic C, every other language will run much more slowly and dock you points.
>>51314667
he was being sarcastic
>>51314308
Bitmasks don't really hurt readability.
They do make things much nicer on the CPU though. Consider the function outlined here: >>51314555
1 boolean for each argument means you're going to end up using all of the registers for arguments, as well as possibly using the stack to store extras. That's a lot of register shuffling for a function call that may end up being repeated. Add in the fact that the function itself may need those registers for other purposes. By comparison, if all of your booleans are stored in one variable using flags, if the flags are constants, the compiler can optimize it all out to a single LI or MOV instruction.
>>51314667
Are structs with bitfields a non-option? I find them more readable than all those arguments and easier to maintain than a bunch of flags.
NEW THREAD NOW
>>51315151
>>51315159
Still 3 pages early, faggot.
>>51315115
They're an option but IMO it hurts readability since you need to either declare and initialize a flags variable, or else use a compound literal (which is ugly and not available in C89).
>>51315269if (flags & MAXIMIZED)
// ...
if (flags.maximized)
// ...
if (maximized)
// ...
I cannot see any appreciable differences in 'readability' between any of those, they all seem perfectly clear and easy to understand.
>>51315353/* C89 */
struct foo_flags flags = {0};
flags.flag_a = 1;
flags.flag_c = 1;
foo(flags);
/* C99 */
foo((struct foo_flags){ .flag_a = 1, .flag_c = 1});
vsfoo(FLAG_A | FLAG_B);
>>51313982
>implying hard mathematical problems use FP
every numerical program i know is in c or fortran
need a new laptop for college and have hard time with figuring out what to get
mostly going to be used for programming, durable and big battery life is nice
what do you guys recommend?
>>51308129
Haha what a fucking nerd