[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: 335
Thread images: 50

File: K&R c.png (1MB, 1000x1400px) Image search: [Google]
K&R c.png
1MB, 1000x1400px
old thread: >>56258339

What are you working on, /g/?
>>
>>56266496
First for D
>>
File: 1369446960901.png (20KB, 256x310px) Image search: [Google]
1369446960901.png
20KB, 256x310px
>>56266496
>Degenerate shit
Kill yourself
>>
File: akari~.gif (415KB, 500x500px) Image search: [Google]
akari~.gif
415KB, 500x500px
Still working on my C comment board!
http://45.32.80.36/board.cgi

I added a post cooldown timer!
>todo: add page browsing, image attachments
>>
unsigned int max = ~0;

>0, of course, is all 0s: 00000000 00000000. Once we twiddle 0, we get all 1s: 11111111 11111111. Since max is an unsigned int, we don't have to worry about sign bits or twos complement. We know that all 1s is the largest possible number.

But what about unsigned? How do I get floats max?
float a = ~0;
printf("%g\n", a);

This gives me -1, which I'm assuming is because of the above stated about signed/unsigned types.
>>
>>56266588
std::numeric_limits<float>::max
>>
Asking for help again. If i can figure out these fucking code tags. I need to have 0 print out "zero". But it keeps fucking up my do while loop. Adding it to the array don't work either.

#include <stdio.h>

int countDigits(int value);
void convert(int number);

char *ones[]={"", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine","ten", "eleven",
"twelve", "thirteen", "fourteen", "fifteen", "sixteen",
"seventeen", "eighteen", "nineteen"};

char *tens[10]={"", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy",
"eighty", "ninety"};


int main(void)
{
int inputNum;
printf("Enter numbers in figures; use a negative value to stop..\n");
// continue running loop until a negative # is entered
do{
printf("\nNumber: ");
scanf("%d", &inputNum);
//special case for zero
/*if(inputNum==0){
printf("zero");
} */
//check if user entered over 999999.
if(inputNum>999999)
{
printf("Only numbers less than 999999.\n");
continue;
}

// call function to convert to english text
convert(inputNum);

}while(inputNum >0);
printf("\n");

}


void convert(int number)
{

if (number > 0 && number < 20){
printf(" %s ",ones[number]);

}else if (number / 1000 > 0) {
convert(number / 1000);
printf(" thousand ");
convert(number % 1000);

}else if (number / 100 > 0) {
convert(number / 100);
printf(" hundred ");
convert(number % 100);
}else if (number / 10 >= 2) {
printf(" %s ", tens[number / 10]);
convert(number % 10);
}

}
>>
>>56266588
>How do I get floats max?

#include <float.h>
// ...
float a = FLT_MAX;


>This gives me -1, which I'm assuming is because of the above stated about signed/unsigned types.
No, floats are floating point numbers.

https://en.wikipedia.org/wiki/IEEE_floating_point
>>
>>56266588
read
https://en.wikipedia.org/wiki/Single-precision_floating-point_format
>>
>>56266623
Uncomment your special case for zero and just add an else statement that checks for everything else. Change your do-while condition to while(inputNum>=0)
>>
>>56266588
 unsigned int max = -1;
is more conventional.

Floats aren't represented like integers. They are represented as scientific notation. I think you might be able to programmatically get the max by filling a float with all ones, then XORing the most significant bit to 0.

It's likely still implementation defined so <float.h> would better help you.
>>
>>56266623

Do

if(!inputNum)    //Equivalent to inputNum == 0
{
printf("zero");
break;
}
>>
>>56266547
SOURCE WHEN
>>
File: me.png (116KB, 1515x663px) Image search: [Google]
me.png
116KB, 1515x663px
>>56266688
Thanks. I had this before. I'm just an idiot and kept entering zero instead of 0 for the prompt.

>>56266750
need to keep prompting until negative number.
>>
Why am I such a fag?
>>
>>56266919
Do you use Functional Programming?
>>
>>56266919
Maybe you should stop sucking so much cock?
>>
>>56266919
>>56266496
?
>>
>>56267058
Still waiting

>>56266730
>>
>>56267026
I am a certified Functional Programming™ user, in fact. Why, is that an issue?
>>
I wrote a filesorting script but it bugs out when it runs into any kind of unusual unicode character.

Is this something I should bother fixing?
>>
File: Capture.png (12KB, 897x241px) Image search: [Google]
Capture.png
12KB, 897x241px
>>56266496
we need new op pics

also, can you guys answer this question. preferably in java or c or c++
>>
>>56266496
Ew
>>
>>56267144
Considering that the whole world (outside of japan) relies on UTF-8 encoding, yes, you should fix it.
>>
The world would be a better place if programming was never invented.
>>
>>56267153
I would like to say that no, I will not do your fucking homework.
>>
>>56267153

how the fuck am I supposed to know the size of the array?
I hope it's a stack array.

a[0] = a[(float) sizeof(a) - sizeof(a[0])] * 2;
>>
>>56267255
i did it, as shown by the green marker covering the answer. but i want to know what you guys would do
>>
>>56267153
a[0] = 2 * a[-1]

toplel c fags gon be suicide watch
>>
>>56267268
>implying we'll fall for your Jewish tricks
>>
>>56267243
"Computers were a mistake" - Allen Turning
>>
>>56267309

They were.
>>
>>56267259
>(float) sizeof(a) - sizeof(a[0])
What the fuck are you even doing?
>>
File: Capture.png (4KB, 191x123px) Image search: [Google]
Capture.png
4KB, 191x123px
>>56267279
a[-1]? im sorry but you seem to be missing something
>>
>>56267335
at first i thought about doing
a[0] = 2 * a[sizeof(a) - ((float) sizeof(a) / sizeof(a[0]))];

but i changed my mind
>>
>>56267259
>how the fuck am I supposed to know the size of the array?

In intelligent languages (NOT C) the length of the array is stored.
>>
>>56267259
why are you casting the index to float
>>
>>56267338
>what is python

>>56267279
that's valid code in C as well btw
it just does something different
>>
File: tulletus apu.png (36KB, 865x526px) Image search: [Google]
tulletus apu.png
36KB, 865x526px
/dpt/

/ Dumb Programming Tards/
>>
>>56267365
sizeof(a) / sizeof(a[0]) - 1
>>
>>56267393
>posting the ribbit frog
go back
>>
>>56267384
>C accepts a negative number as an index

WHY
>>
>>56267393
oh yeah post what you're working on then, tough guy
>>
Experimenting with parsing JSON.
protected void onCreate(Bundle savedInstanceState) {

//Set up activity, usual stuff

json = LoadJSON();
PopulateList();
}
private void PopulateList() {
JSONArray jsonArray = null;
try{
JSONObject jsonObject = new JSONObject(json);
jsonArray = jsonObject.getJSONArray("items");
for (int i = 0; i < jsonArray.length(); i++){
JSONObject obj = jsonArray.getJSONObject(i);
String name = obj.getString("title");
String description = obj.getString("description");
String upc = obj.getString("upc");
String ean = obj.getString("ean");
ProductItem productItem = new ProductItem(name, description, upc, ean, null, null);
adapter.add(productItem);
}

} catch (JSONException e){
e.printStackTrace();
}
}
String LoadJSON() {
BufferedReader in = null;
try {
StringBuilder buf = new StringBuilder();
InputStream is = this.getAssets().open("TestJSON.json");
in = new BufferedReader(new InputStreamReader(is));
String str;
while ( (str = in.readLine()) != null ) {
buf.append(str);
}
in.close();
return buf.toString();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return null;
}
>>
>>56267338
Does mine work? I wanna know.

a[0] = a[sizeof(a) - sizeof(a[0])] * 2;
>>
>>56267418
because
arr[idx]
is just syntactic sugar for
*(arr+idx)
where idx can be a negative number.
here's an example: http://ridiculousfish.com/blog/posts/old-age-and-treachery.html
>>
>>56267445
No. Take uint16_t a[4]. 8 - 2 = 6, out of range.
>>
>>56267429
Reading this literally makes me physically sick.

public class Product
{
public string name;
public string description;
public string upc;
public string ean;

public Product(string n, string d, string u, string e)
{
name = n;
description = d;
upc = u;
ean = e;
}

public static List<Product> LoadFromJson(string path)
{
return JsonConvert.DeserializeObject<List<Product>>(File.ReadAllText(path));
}
}
>>
File: capture.png (51KB, 657x527px) Image search: [Google]
capture.png
51KB, 657x527px
>>56267413
okay ill go back here

>>56267423
im not working on anything

/dpt/

/ Depressed Puny Trimjobs /

>>56267445
it only takes java code
>>
>>56267494
I'm using Java, though. It doesn't have C# one-liners for a lot of stuff.
>>
How do I use SQL in C on OSX?

I've downloaded unixodbc and it's linked yet when I gcc -o x x.c i get the error
fatal error: 'sql.h' file not found
>>
>>56267606
use sqlite you retard
>>
>>56267494

Thank god for C-SHARTing in mart.
>>
>>56267609
cheers nigga saved me the headache
>>
File: riYkjFt.png (25KB, 723x412px) Image search: [Google]
riYkjFt.png
25KB, 723x412px
>>56267654
Hey OSGTP, I can't seem to put 2 and 2 together on this one.

Why on earth is there such a difference in execution time here?

Am I being dense and missing something obvious?
>>
File: v9DDaQl.png (8KB, 925x61px) Image search: [Google]
v9DDaQl.png
8KB, 925x61px
>>56267719
Ah right, figured it out.
>>
I just sent in an application for a job which I was supposed to send in my salary requirements but forgot to do so in my initial application email and I had to send it in separately as a separate email.

Am I stupid/autistic for worrying if this will affect my chances? Either way, someone kill me, I feel horrible right now.
>>
>>56267831
giv address pls, ill hire someone
>>
>>56267895

>hiring from /g/

Seriously, why would anyone do this? All we post are interview-tier stuff that gets met with pajeet-tier code.
>>
>>56267935
I'd be saving people from NEEThood.
>>
>>56266770
I'll post it when it's reasonably feature-complete.

Right now it drags the entire database into memory on every page reload.
>>
>>56268069

Holy crap, why? That is really inefficient.

>>56267942

I moved to the Bay Area and I doubt you would want to hire me unless you're looking for entry level people.
>>
>>56268089
That is really inefficient.
I think that's the reason why. Most people don't want to share code they know is low-quality.
>>
>>56268089
>>56268109
I'll be adding page offsets in a bit, calm down.
>>
Artificial intelligence design of novel antenna shapes.
>>
>>56268219
Genetic algorithms?
>>
>>56268219
Pls post pics anon kun
>>
>>56267153
Isn't this just fine?
a[0] = 2 * a[sizeof(a) - 1]
>>
>>56268587
>implying sizeof gives array length all the time
>>
File: pro-font.png (9KB, 538x316px)
pro-font.png
9KB, 538x316px
Just started using pro-font. I don't know whether I love it or hate it, yet. Anybody else using it?
>>
>>56268597

It doesn't at all 100%. You have to divide the sizeof of the array by its first element to get the length accurately.
>>
>>56268587
i guess

in java just replace 'sizeof' with 'a.length'
>>
>>56267429
Java already looks disgusting enough, why must you people actively make it look even more disgusting?
>>
>>56268616

Now try doing that after having passed the """""""""""array"""""""""" to a function.
>>
File: java poogrammer.png (371KB, 800x600px) Image search: [Google]
java poogrammer.png
371KB, 800x600px
>>56268601
>java
>>
>>56268662
What languages should be learned in order to avoid the shitstorm of Pajeets?
>>
>>56268662
>>java
>>
>>56268681
D
>>
>>56268681
scheme
>>
>>56268692
Even though I know you're a microcuck, what you wrote is practically indistinguishable from Java, with the only difference I can spot being "bool".
>>
I honestly don't think you can avoid Pajeets, especially if you're at a larger company.

Just learn how to understand Pajeet English already.
>>
>>56268681
haskell
you can avoid anyone really, you'll have no friends
>>
>>56268779

The lack of try/catch everywhere should be a good indicator.
>>
import System.Environment (getArgs)
import Data.Bits

main = getArgs >>= pcross . read . head
where pcross = mapM_ putStrLn . cross

cross n = half ++ [space (length half) ++ "*"] ++ reverse half
where make v = flip (++) [" "] . takeWhile (/=" ") $ iterate (init . tail) (space v)
padding = zipWith (\x y -> space x ++ embrace y) [0..]
embrace = (++"*") . ('*':)
space j = replicate j ' '
half = padding (make $ (n.|.1) - 2)
>>
Newbie question. Im going through some books, building mostly basic console command programs using Dev c++. Can i get the computer to run these programs from the console itself? Like without opening them in dev? There's no real reason to im just wondering.
>>
Hello my name Pajeet I expert Java programer.
>>
>>56268895
yes
>>
>>56268597
>>56268616
That's interesting, thanks.
>>
>>56268913
Kindly do the needful and update status of customer . Regards, Raj Sripanasakanlandakapoor
>>
>>56268616
Wrongo dood
>>
>>56268882
so inefficient
try cross 9000
>>
>>56266547
First person on DPT actually taking some fucking initiative. Good on ya
>>
>>56268601
I think it looks cool
>>
>>56268882
lmao this is unreadable
>>
>>56268643
>>56268978

Who wouldn't pass a size parameter when you need it and you're passing an array? I never claimed that sizeof(array) / sizeof(array[0]) will work everywhere, just the notion that sizeof(array) will not return the size of the array all the time, when the size of the element in an array is not 1 byte exactly or you are working with a pointer. Read the damn post again.
>>
File: c++ in a nutshell.png (72KB, 1016x98px) Image search: [Google]
c++ in a nutshell.png
72KB, 1016x98px
>>56268882
You hasklel idiots fell for the same trap that the sepples community did (pic related)

That is why lisp will always be superior to hasklel
>>
"ECC in workstation is better!", they say.
but life has taught me that there always a give and take. what goes up, must come down.

tl;dr
are there any CONS to ECC memory vs non-ECC when all else is the same?
>>
>>56269134
asking specifically for beefy workstations, heavy IDEs and emulating android, running VMs, compiling huge programs.
>>
>>56269134
Why the hell are you asking that in the programming thread?
>>
>>56269134
Do you
A.) plan to run your computer for a year or more?
B.) plan to be running code that could potentially cost you millions of dollars or kill people?
C.) plan to be operating you computer in space and/ or a high radiation environment?
If you answered no to all of these, you don't need ECC RAM.
>>
>>56268681
Racket
>>
prentf("Hello");
>>
File: fuck you.webm (199KB, 960x1080px) Image search: [Google]
fuck you.webm
199KB, 960x1080px
>>56268990
What are you talking about, it isn't that slow.
>>
>>56269155
programmers use workstations for job
very experience
such knowledge
many wow
see:
>>56269172
>>
>>56269172
thanks mang
>>
>>56269189
>That entire post
Jesus christ, kill yourself.
>>
File: 1415933327236.jpg (39KB, 400x366px)
1415933327236.jpg
39KB, 400x366px
>>56269205
Not him, but you should take up your own advice
>>
>>56267153
myArray[0] = (sizeof(myArray)/sizeof(myArray[0])) * 2;


I have no idea if that works, but that's sort of what I'd do in C.
>>
Is Programming: Principles and Practice Using C++ by Stroustrup a good first book?
>>
>>56269262
No. Stay the hell away from that clusterfuck of a language.
>>
>>56269262
Nuhuhu, learn C.
>>
File: C++.png (34KB, 200x209px) Image search: [Google]
C++.png
34KB, 200x209px
>>56269262
It depends, do you want your code to look like this? >>56269080
>>
>>56269303

Cat++ would be better than cat, though. cat is an asshole.
>>
>tfw no multiple inheritance in CuteSharp
>>
>>56269274
>>56269291
>>56269303
Slightly concerned face.

/Sci/ told me c fanboys are bad, but i really cant tell if this is sincere or not. They said to avoid java too, which i sort of already know to some degree or another
>>
Reminder that Haskell a shit.
>>
>>56269365
I only suggested C because it's fucking simple to learn to prorgam with, once you understand memory, pointers, stacks, heaps, references, allocations, branches, functions, and all that nitty gritty things you can move to a higher level language and start making things faster.
Sepples is a nice language too, but it's a level higer from C and prolly you wouldn't understand some things.
I've learned a bunch of langs, php, C, ruby, C++, and now C# is my tea of cup.
>>
>>56267243
Then fuck off and kill yourself already.
>>
>>56269365
Well what are you trying to program, first of all?

If you came from /sci/, you probably want something for numerical computing, right? So probably try learning something like Matlab, R, or python, depending on what your exact application is. If you could provide more information on what you want to do, I could offer you some better advice on what your ideal language is.
>>
>>56269407
So start low, that seems logical since you would get good at resource management right?
>>
>>56269422
It depends. If you want to write code for operating systems and microcontrollers, that's good advice. Otherwise refer to >>56269417
>>
>>56269417
Not specifically from sci, i read the wiki then came to dpt.

I cant say i really have an end goal, i think encryption and security looks kind of cool if that helps
>>
>>56269417
FORTRAN and Julia are good for number crunching
>>
>>56269422
Yep, even now with C# that knowledge serves me to not going stupid and creating a lot of objects every time I change a ViewModel in my applications, that otherwise those objects were going to be GC.
>>
Which one would be faster?
SELECT id FROM table ORDER BY id DESC LIMIT 1;
SELECT MAX(id) FROM table;
>>
>>56269377
data poster deteceted
write that program I told you about yesterday
>>
>>56269440
> i think encryption and security looks kind of cool if that helps
Then C would be a good choice.

Though what's your degree in?
>>
File: 21f.jpg (35KB, 600x568px) Image search: [Google]
21f.jpg
35KB, 600x568px
>>56269377
>>
>>56269080
And that's what haskell/scala fags are always going on about is how their languages are inherently easier to understand despite looking like complete trash. LISP really is the superior language in the functional domain.
>>
>>56269454
I have no idea what you're talking about.
I was just testing out clover.
>>
File: 1416928491388.gif (731KB, 200x202px) Image search: [Google]
1416928491388.gif
731KB, 200x202px
>>56269454
>implying that was me
And no, I'm going to bed again just to taunt you :^)
>>
>>56269468
>Haskell and Scala look like complete trash
>((((((((((((((((((((((((((((((((Lisp)))))))))))))))))))))))))))))))))) somehow looks better
>>
>>56269408

That's awfully rude.
>>
File: bjarne blew it.jpg (353KB, 870x500px) Image search: [Google]
bjarne blew it.jpg
353KB, 870x500px
>>56269080
>using typedef
>not defining ReturnType in the template declaration
>>
I need to do some serious research into parsing.
I'm using C for this.
What do?
I'd like to be able to implement a recursive descent parser.
>>
>>56269481
At least that's the entire syntax and not the 6 gorrilion symbols haskell has
>>
>>56269468
Sepples and Hasklel both look like cancer because their development teams are both led by autists that sit on their ass all day and think of more useless autism-arousing concepts to throw into the language. In comparison, the development of Lisp has always been driven by specific external purposes, such as AI and symbolic computing, and not intellectual stimulation.
>>
File: akari!.jpg (2MB, 1300x1560px) Image search: [Google]
akari!.jpg
2MB, 1300x1560px
>>56268089
>>56268109
Alright, I fixed my database fetching code.
Now the post cooldown calculator only fetches posts made in the last 30 seconds to compare IPs against.
>>
>>56269463
My degree is just called "computer science" 2nd semester in ive done an intro in java and am doing mysql sruff currently. Other than that ive done calculus.
>>
>>56268662
>using a primitive type comparator with objects

== only works for numbers between -128 and 127. There's a reason equals() exist.
>>
>>56269601
>Java
>>
>>56269609
that was fast
>>
File: for_what_purpose.png (63KB, 272x488px)
for_what_purpose.png
63KB, 272x488px
>>56269601
>== only works for numbers between -128 and 127
What the fuck? Lol
>>
File: dissaproval.jpg (27KB, 314x246px) Image search: [Google]
dissaproval.jpg
27KB, 314x246px
>>56269601
a-are you memeing? There's no way this is real, r-right???
>>
>>56269525
Saw this code here a few days ago:
(dotimes (i n)
(format t "~%~:[~d~:;~:*~{~c~^~}~]"
(append (and (zerop (rem i 3)) (coerce "fizz" 'list))
(and (zerop (rem i 5)) (coerce "buzz" 'list)))
i))


>"~%~:[~d~:;~:*~{~c~^~}~]"
Nice syntax lispfags, even when you don't use parentheses you find a way to make it even uglier.
>>
>>56269632
255 you dingo
>>
>>56269651
I'm not sure what it is that blows your mind.
>>
>>56269601
So what's the reason, is it comparing the first byte stored in the reference or something?

>>56269668
Nice try but that's not syntax, it's a string literal and those exist in nearly every language.
>>
File: what the fug.png (11KB, 211x246px) Image search: [Google]
what the fug.png
11KB, 211x246px
>>56269601
>== only works for numbers between -128 and 127.
>>
>>56269689
>format strings
>not part of the language
>>
File: 1471191022029.jpg (194KB, 640x800px) Image search: [Google]
1471191022029.jpg
194KB, 640x800px
>>56269609
>>56269632
>>56269651
>>56269674
>>56269689
>>56269691
Please disregard this pajeet-tier answer
>>
>>56269689
Here there's a good explanation:

https://vijayanbu001.blogspot.cl/2016/07/identity-vs-equality-comparison-of.html
>>
>>56269632
>>56269651
>>56269691
>>56269689
It is real, but it only applies to the boxed Integer type, not the primitive int. See, normally it wouldn't work at all, because the == operator compares addresses when you apply it to objects. However, Java has "interned instances" for those particular Integer values, because they're the most common.
>>
>>56269697
So? Lisp's format facility is one of the most versatile and useful among all programming languages.
>>
>datafag can't even make an ncurses filesystem browser in his (((((language))))))
>>
File: bollywood poo.jpg (66KB, 401x400px) Image search: [Google]
bollywood poo.jpg
66KB, 401x400px
>>56269712
>linking to a poo in loo
>>
Is Lisp syntax similar to Scheme?
>>
>>56269757
Scheme is an implementation of lisp
>>
taking a statistics class in college. My professor says statistics is number crunching so use whatever calc you want. So I made a few programs that'd streamline statistics.
>>
>>56269772
Just use any decent stats library. Or better yet an entire language dedicated to statistics: R
>>
>>56269802
lisp is better
>>
>>56269516
If you're serious about parsing, read the first few chapters of the dragon book.
Once you get a LL(k) grammar, it isn't too hard to write a recursive decent parser from that.
/* 
* add ::= mul '+' mul
* | mul '-' mul
* | mul
*
* mul ::= val '*' val
* | val '/' val
* | val
*
* val ::= '(' add ')'
* | [0-9]
*/

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int parse_add(const char *, int *);

int parse_val(const char *s, int *i)
{
if (s[*i] == '(') {
++*i;
int ret = parse_add(s, i);

if (s[(*i)++] != ')') {
printf("parse error\n");
exit(1);
}

return ret;
} else if (isdigit(s[*i])) {
++*i;
return s[*i - 1] - '0';
} else {
printf("parse error\n");
exit(1);
}
}

int parse_mul(const char *s, int *i)
{
int ret = parse_val(s, i);

if (s[*i] == '*') {
++*i;
return ret * parse_val(s, i);

} else if (s[*i] == '/') {
++*i;
return ret / parse_val(s, i);

} else {
return ret;
}
}

int parse_add(const char *s, int *i)
{
int ret = parse_mul(s, i);

if (s[*i] == '+') {
++*i;
return ret + parse_mul(s, i);

} else if (s[*i] == '-') {
++*i;
return ret - parse_mul(s, i);

} else
return ret;
}

int main(int argc, char *argv[])
{
if (argc == 1)
argv[1] = "3+2*1";

int n = 0;
printf("%d\n", parse_add(argv[1], &n));
}
>>
>>56269920
Fuck, I just realised my grammar was wrong.
I'll post the correct version soon.
>>
File: 1467787744612.jpg (111KB, 678x960px) Image search: [Google]
1467787744612.jpg
111KB, 678x960px
How many of you use amphetamines on a regular basis? Do you feel they improve your programming? Do you enjoy programming while on them?
>>
>>56269743
>implying loos can't be good programmers
fuck off with this racist shit, i bet you /pol/ fags would talk shit on ramanujan too
>>
File: le pill popping rubio.gif (3MB, 162x288px) Image search: [Google]
le pill popping rubio.gif
3MB, 162x288px
>>56270073
>taking the pharma jew
>>
>>56270093
>ramanujan
Overrated, Galois was much smarter and more insightful than him.
>>
>>56270114
Also dumb enough to get into a duel over a woman
>>
File: 1438973355145.jpg (42KB, 626x335px) Image search: [Google]
1438973355145.jpg
42KB, 626x335px
>>56270104
Get lost poltard.
>>
File: 1438939548224.png (744KB, 700x556px)
1438939548224.png
744KB, 700x556px
>>56270104
No one cares about you stormfag. Go back to your containment board.
>>
>>56270114
>Galois
>muh extensions
>muh polynomials
>muh useless abstract algebra
Nice meme rofl.
>>
>>56270134
Ramanujan would never get into a duel over a woman because he preferred little girls.
>>
File: 1437530719838.gif (1MB, 620x566px) Image search: [Google]
1437530719838.gif
1MB, 620x566px
>>56270104
Get back to >>>/pol
>>
>>56270073
It doesn't improve my programming but it lets me code for however long i need to. And yeah everything's great fun on speed i can happily sit down and spend 6 straight hours ironing out whatever kinks are left in my latest stim fueled project.
>>
>>56270162
>i don't understand it, so it's useless
Spoken like a true pajeet.
>>
>>56270193
>I only know how to set up strawmen
Name one application of Galois theory outside of commutative algebra.
>yfw you can't
>yfw even algebraic geometry has applications in cryptology
>yfw even algebraic topology has applications in physics
>yfw even Morse theory has applications in analysis
>yfw even category theory has applications in quantum computing
Rofl. Fucking retard,
>>
>>56270008
>>56269920
Ok, here was the correct version.
Writing the damn grammar is the hardest part of this shit.
/* 
* add ::= mul add2
*
* add2 ::= '+' add
* | '-' add
* | ''
*
* mul ::= val mul2
*
* mul2 ::= '*' mul
* | '/' mul
* | ''
*
* val ::= '(' add ')'
* | [0-9]
*/

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int parse_add(const char *, int *);
int parse_mul(const char *, int *);

int parse_val(const char *s, int *i)
{
if (s[*i] == '(') {
++*i;
int ret = parse_add(s, i);

if (s[(*i)++] != ')') {
printf("parse error\n");
exit(1);
}

return ret;
} else if (isdigit(s[*i])) {
int num = s[*i] - '0';
++*i;
return num;
} else {
printf("parse error\n");
exit(1);
}
}

int parse_mul2(const char *s, int *i)
{
if (s[*i] == '*' || s[*i] == '/') {
++*i;
return parse_mul(s, i);
} else {
return 1;
}

}

int parse_mul(const char *s, int *i)
{
int val = parse_val(s, i);

// I bit of a hack, because we can't
// return "divide values" from parse_mul2
if (s[*i] == '/')
return val / parse_mul2(s, i);
else
return val * parse_mul2(s, i);
}

int parse_add2(const char *s, int *i)
{
if (s[*i] == '+') {
++*i;
return parse_add(s, i);
} else if (s[*i] == '-') {
++*i;
return -parse_add(s, i);
} else {
return 0;
}
}

int parse_add(const char *s, int *i)
{
return parse_mul(s, i) + parse_add2(s, i);
}

int main(int argc, char *argv[])
{
if (argc == 1)
argv[1] = "3+2*3";

int n = 0;
printf("%d\n", parse_add(argv[1], &n));
}
>>
>>56270230
>Name one application of Galois theory outside of commutative algebra.
Algebraic geometry, elliptic curves, number theory, cryptography (Galois fields), etc. Wiles' proof of Fermat's Last Theorem relies on Galois theory. But that doesn't matter, unlike what your curry and feces filled mind thinks, theory can have meaning and beauty independently from applications.
>>
File: img_106.png (306KB, 414x404px) Image search: [Google]
img_106.png
306KB, 414x404px
>>56270312
>tries to name applications of Galois theory outside of comm. alg.
>names applications of Galois theory inside comm. alg.
If only everyone loves pulling shit out of their asses as much as you kek. Keep clinging on the pajeet schtick kid since that's the only thing preventing you from realizing your complete ineptitude.
>beauty
>in anything but topology
>MUM WATCH ME PUSH SYMBOLS LMAO
Dumbfuck rofl
>>
File: landwhale lmaoing @ your life.jpg (12KB, 205x205px) Image search: [Google]
landwhale lmaoing @ your life.jpg
12KB, 205x205px
>>56270351
>pshh, fermat's last theorem is just comm alg kiddo

Not to mention, group theory wouldn't exist today if it weren't for Galois, and that means no representation theory, no combinatorics, no Lie theory, etc.
>>
File: smug13.png (36KB, 268x237px)
smug13.png
36KB, 268x237px
>>56270415
>number theory isn't comm. alg.
>numbers don't commute
>numbers isn't part of algebra
Rofl.
>group theory wouldn't exist today if it weren't for Galois
Except Euler and Lagrange both worked on it years before Galois did lmao. And the parts of group theory that matters to representation (vector spaces) and Lie (manifolds) theory have nothing to do with polynomials or Galois theory kek.
>this fucking retarded
>who is Holder
>who is Abel
>who is Hilbert
>implying a 19 year old fuccboi matters this much to a field of mathematics this massive
How embarrassing. It's as if you only learned about Galois from pop media sources.
>>
>>56270469
>It's as if you only learned about Galois from pop media sources
>, he says as he fawns over ramapoojan
>>
File: file.png (134KB, 919x539px) Image search: [Google]
file.png
134KB, 919x539px
>>56270508
>implying I ever did
>implying I was >>56270093
>implying I'd defend some faggot who 1.) thought he could talk to "Gods" and 2.) died because he couldn't poo in loo in England
>implying you're not just another retard Galois asslicker
>implying you have any arguments aside from pathetic strawmen
Kill yourself rofl. This is the typical level of discourse from /g/.
>>
>programming
>>
File: Untitled.png (72KB, 825x187px) Image search: [Google]
Untitled.png
72KB, 825x187px
>>56270549
I can inspect element too, you know :^)
>>
>>56270571
>dude he edited the webpage and took a screenshot within a minute rofl
>grasping at straws this hard
>this pathetic
Never fucking reply to me ever again unless you're contributing to the thread.
>>
>>
File: back_to_reddit.png (9KB, 355x46px) Image search: [Google]
back_to_reddit.png
9KB, 355x46px
>>56270623
>back end
>implying he isn't just prepping the bull
>>
>>56270640
This should be front page :D
>>
>Doing government sponsored C# programming course for NEETs in order for them to get a job.
>Guy behind me browsing 4chins
>He was also browsing Reddit before that
>Now he's on 9gag
>He hasn't done anything yet this week

How often do you encounter fellow 4channers during your programming courses/work?

Are they walking stereotypes like this guy is?
>>
>>56270938
Everyone (else) on my course is a redditor
>>
>>56270938
Oh god don't remind me of my uni years. Reddit had just taken the mantle from Digg (which had redesigned and in the process completely killed itself) - everyone was hardcore into Redditing, Atheism, and Touhou.
>>
>>56270999

The worse part is the Touhou popularity getting mainstream attention. Secondaries are getting insufferable because of that. Same with other franchises.

I should not have to suffer from ignorant people inside my hobby. Either you read the goddamn source material or shut up.

In any case, it was MLP during my university years that was all the rage. But meh, my university was completely OOP biased so my software engineering classes were insufferable.
>>
>quoting from last thread
>Hey, I don't know if you're still there, but you described the perfect job opportunity for me. If you reply I can give you a contact medium.

Drop me your telegram
>>
>>56271254
-.-- --- ..- .----. .-. . / .- / ..-. .- --.
>>
>>56271198
>The worse part is the Touhou popularity getting mainstream attention. Secondaries are getting insufferable because of that.
It fucking sucked, but it seems to have let up some since kancolle won over a lot of the secondaries.
>>
>>56271270
.-.. --- .-.. --- .-.. --- .-.. --- .-.. .-.. .-.. .-.. / -..- -.. -.. -.. # # # # # .---- ..--- .---- .---- .---- .---- .---- ..--- ...-- ....-
>>
>>56266812


This pictures triggers me so much..

>fuuu6 gets resolved as number
>$%&a gets resolved as word
>"§() gets resolved as "number and a word"
>>
>>56267026

Do you use JavaScript?

Because map / reduce / forEach / filter is already functional programming, baby..
>>
>>56267153
a[0] = a[a.len() - 1] * 2
>>
>>56267429
Why does Java still exist.
>>
>>56271382
>map reduce filter
>we /fp/ now?

I fucking hate you
>>
File: mOnvOJG.jpg (57KB, 480x270px) Image search: [Google]
mOnvOJG.jpg
57KB, 480x270px
>someone takes your code from github and makes his own project with it

i dont like open source... not like this.
>>
>>56271481

I take it that you are a hasklel fag?

Then I got news for you: "funtional programming" is not a boolean. You can include functional paradigms into a language or leave them.

For example Currying (--> who is Haskell Curry?) is also part of JS. Closures are part of JS. Functionas are first class objects in JS, you can pass them to functions or take them as return values. How is that not functional?


On the other hand the "holier -than-though" haskell langauge isn't homoiconic like Lisp.


Conclusion:
Either LISP is the only functional langauge out there.
Or every langauge can have a certain degree of functional-features in it.
>>
>>56271723
Did I trigger you this badly?

You need more than map/filter/reduce to be functional

>currying
Enjoy your five hundred nested lambdas.
Your language doesn't have currying built-in and there's no point trying to mimic it.
>>
File: ftfy.gif (13KB, 180x236px) Image search: [Google]
ftfy.gif
13KB, 180x236px
>>56271745

>Your language doesn't have currying built-in and there's no point trying to mimic it.

How is currying not built-in in JS? Do you even know the language?

But more important, currying is the "way to go" in JS. It's not a theoretical feature, it's just how you do it.

I guess you somewhere read that functional langauges must have immutable values or something. That's ONE point among many.

So while nobody would claim that JS is a "pure" functional language, definately has a heave emphasis on functional programming techniques.
>>
>>56267153

// Java
a[0] = a[a.length - 1] * 2;
>>
>>56271787
>how is currying not built in?

add = function(a,b){ return a + b; }
x = add(3)(4)
a4 = add(4)
y = a4(3)

>...
You write more in response to what I've never said than you do to what I've actually said
>>
>>56267259

why not:
a[0] = a[sizeof(a) / sizeof(a[0]) - 1] * 2;


i'm kinda new to C++ so i'd like to know personally
>>
>>56267153
a[0] = a[-1]*2
>>
>>56271833


Never heard of functional.js ?
>http://functionaljs.com/

var add = fjs.curry(function(arg1, arg2, arg3) {
return arg1 + arg2 + arg3;
});
var add3 = add(3);
var add5 = add3(2);
add(3)(2)(1);
add3(2, 1);
add3(2)(1);
add5(1);



>hurry, libraries are bad!

OK, then take one sec and make a random arguments currying yourself:
function curry(fx) {
var arity = fx.length;

return function f1() {
var args = Array.prototype.slice.call(arguments, 0);
if (args.length >= arity) {
return fx.apply(null, args);
}
else {
return function f2() {
var args2 = Array.prototype.slice.call(arguments, 0);
return f1.apply(null, args.concat(args2));
}
}
};
}

// now we can do this:
x2 = sumFour(1)(2)(3)(4);
>>
>>56271965

Sorry, at the second exmaple I forgtot this:

var sumFour = curry(function(w, x, y, z) {
return w + x + y + z;
});
>>
>>56271965
>>56271975
If you have to call a function "curry", that's not even from the base fucking library, then it's not built in, is it?
>>
>>56271983

In C I have to include "<stdio.h>" to use "printf".
I guess C has no I/O then?

You are caught by prefixed thoughts about "what is functional programming". Wether you have to implement a function or not is not the important part. The important part is wether it is some "funky feature" of the language or something that is the "nomal way of doing things". I have yet to see a JS introductional book that doesn't explain currying and has it's own (short) introductin of the functional aspects of JS.

But I'm gonna argue with morons here.
>>
>>56272026
Holy shit you can't be this desperate

I guess my language has struct definitions built in if I have to find a library online, import it, then call a function manually to define a struct
>>
>>56272026
>>56272045
In fact, I guess since you can find a library for almost anything, EVERY language has EVERYTHING built in
>>
>>56272026
>In C I have to include "<stdio.h>" to use "printf".
Your program always has the standard library functions linked in, even if you don't include the header, unless you're writing freestanding C.
Using some memetic javascript library doesn't count as "part of the language".
>>
>>56269451
on SQLite:
>
SELECT MAX(id) FROM table;

is pretty much guaranteed to be faster

sqlite> EXPLAIN QUERY PLAN SELECT MAX(price) FROM product;
0|0|0|SEARCH TABLE product


^ does a single scan

sqlite> EXPLAIN QUERY PLAN SELECT price FROM product ORDER BY price DESC LIMIT 1;
0|0|0|SCAN TABLE product
0|0|0|USE TEMP B-TREE FOR ORDER BY


^ has to sort the entries
>>
File: Hasklel.png (2KB, 336x52px)
Hasklel.png
2KB, 336x52px
>>56272052

>EVERY language has EVERYTHING built in

You don't understand much of langauge design..

Try to build currying in Java.. it's veyr hard and the results will be very disappointing.
>https://dzone.com/articles/whats-wrong-java-8-currying-vs

JS is more like Lego or C you have to build a lot of stuff for yourself, but that doesn't mean it's not suited for using that stuff you build.
>>
so /g/ i'm needing some help here

in C++, i'm writing a geometry thing which detects collisions to other shapes

i made an abstract Shape class which has an std::vector of Points.

i have a
Polygon
class which has an 'intersects' function it gets from shape, and here's where my problem lies

here's the prototype:
bool intersects(const Shape& shape) override;


from what i've heard, it's better to take in a const reference than just a reference. the code seems to get more complicated when i write it out like this though.

so in java (incase you couldn't tell from the shit i've said here so far my brain is currently wired to think oop) there's an 'instanceof' keyword which i'm used to and i tend to use it quite a bit, although i hear it's bad practice despite its convenience. in C++ i haven't really found a good alternative to that yet, so what i did is create an enum of shape types (Polygon, Line, etc) and if i need to add in a specific case for something (like lines, for example) i check which type it has.

so, in java, what would be
if (shape instanceof Line)
has now turned into:
if (shape.getType() == ShapeType::LINE)


i feel kinda dirty using it, but that aside...
after i do that check, i create a pointer to the shape i'm checking the type of using:
Line* li = const_cast<Line*>(reinterpret_cast<const Line*>(&shape));


this shit looks so messy to me i swear

had i just passed in a shape reference i could use dynamic_cast and be done with it, but honestly everything i'm writing is just looking like duct tape and cardboard and i'd like to know what the preferred option here would be
>>
>>56272143
>You don't understand much of language design
I fucking told you it didn't have currying built in and you said "but it is built in because there are external not built in libraries"

Doesn't even matter, what's the point having a curry function if it's not built into function application? Defeats the entire purpose. May as well use lambdas to rebind,
>>
>>56272182

You said:

>Your language doesn't have currying built-in and there's no point trying to mimic it.

For me, "built-in" means it's in the standard lib or can be very easily be included. Guess we won't reduce this (no pun intended) to a common denominator here.

But saying "there's no point trying to mimic it" is just wrong. That's like saying:

"C doesn't have liked lists built-in and there's no point trying to mimic it."
>>
>>56272221
>For me, "built-in" means it's in the standard lib or can be very easily be included. Guess we won't reduce this (no pun intended) to a common denominator here.

How the fuck is that "built in"?


>...
It is stupid to try and mimic it.
It gives you no real advantage if it's not part of the language.
>>
>>56269326
You can essentially do multiple inheritance using interfaces.
>>
>>56267259
Doesn't sizeof return the number of bytes?
>>
File: anal beads.png (6KB, 193x93px)
anal beads.png
6KB, 193x93px
I swear this guy's full-time job is to answer questions on SO.

He's fucking everywhere, immediately after questions are asked, with a descriptive, helpful answer.

God Bless Jon Skeet

Last name implies ejaculation, too, which is pretty cool, I guess.
>>
>>56272221
I'll agree with you here m8.
>"C doesn't have liked lists built-in and there's no point trying to mimic it."

Post implementations of functional idioms in other languages!
local function flatten(t)
local ret = {}
for _, v in ipairs(t) do
if type(v) == 'table' then
for _, fv in ipairs(flatten(v)) do
ret[#ret + 1] = fv
end
else
ret[#ret + 1] = v
end
end
return ret
end

function curry(func, num_args)
num_args = num_args or debug.getinfo(func, "u").nparams
if num_args < 2 then return func end
local function helper(argtrace, n)
if n < 1 then
return func(table.unpack(flatten(argtrace)))
else
return function (...)
return helper({argtrace, ...}, n - select("#", ...))
end
end
end
return helper({}, num_args)
end

function bind(f, ...)
local argtable = table.pack(...)
return function(...)
local t = table.pack(...)
local j = 1
for i = 1, t.n do
while argtable[j] ~= nil do j = j + 1 end
argtable[j] = t[i]
end
return f(table.unpack(argtable, 1, math.max(j, argtable.n)))
end
end
>>
Just finished an interview for a postdoc position and on top of generally doing very well I was asked the best question ever.

We were talking about how I would approach a particular problem and the professor in charge asked if I've heard of a certain program (really just a fancy parser for the sort of data used in such problems which also generates useful summaries).

I answered truthfully that I developed it. He seemed quite impressed.
>>
>>56268662
Python does this too for integers greater than 1024 if I'm not mistaken.
>>
>>56272438
Well python has overloading.
>>
>>56272438
You are mistaken.
>>
>>56272438
there are a lot of integers greater than 1024
>>
I spent the past hour agonizing how to do a function inverse on a set of values in an array where say if a function f(1) = x then g(x) = 1 for each value in the set where they are bijective aka each value in the set point to each other when applied with a function.

I assumed that using a 0 indexed array, if I had a value arr[i], I would traverse the array with an index j and when j + 1 is equal to arr[i], I had to return arr[arr[i] - 1]. Turns out no, the solution was to pass back i + 1.

The whole thing is confusing and screwing with my mind at the moment but I'm glad I figured it out.
>>
>>56272528
I have no idea what you're talking about.
>>
>>56272528
arr[i] = x
arr(i) = x
arr-1 (x) = i
>>
>>56272348
>I swear this guy's full-time job is to answer questions on SO.
It actually is. He's like THE expert on C# or something, that's his shtick. I'm pretty sure he has written several books and SO is part marketing, part research for him.
>>
>>56272528
There are a ton of ways to do that. Simplest would be:
arr[i] == x; i == arr.IndexOf(x);
>>
This is a 32bit AT&T syntax assembly program:
movl $SYS_OPEN, %eax    # system call 5
movl $STDERR, %ebx # ebx - device
movl $O_RDONLY, %ecx # ecx - file access bits
int $LINUX_SYSCALL # call it
movl %eax, ST_ERR(%ebp)# put the result on stack

movl $SYS_WRITE, %eax # system call 4
movl ST_ERR(%ebp), %ebx # resulting error
movl STDOUT, %ecx # write to stdout
int $LINUX_SYSCALL # call it


so it seems to be working except the error code prints the ASCII representation of what I guess is the error.
For example, when the program runs fine, nothing is output to STDOUT. However, when I get an error,
ÿÿ%
is outputted. I know the percent sign is sometimes from a lack of null terminating character. SYSWRITE does have a number of bytes to write. I thought an error code would only be 1 byte so I'm not sure why two ASCII characters are there. Any thoughts? I just want the number of the error code.
Am I going to have to convert it while it's on the stack? Is that even the error code?
>>
God fucking damnit, I hate VB/VBA SO FUCKING MUCH.

The syntax is fucking shite, man!

Anyone know what the living shitfuck is wrong with this bit of code?
    Dim cs As Worksheet
cs = ActiveWorkbook.ActiveSheet

cs.Sort.SortFields.Clear
cs.Sort.SortFields.Add Key:=Range(rangeFinal), _
SortOn:=xlSortOnValues, _
Order:=xlAscending, _
DataOption:=xlSortNormal


I have tried to fix that Sort in at least 8 different ways, and I'm totally fucking out of ideas.

If it wasn't necessary to use VBA for my client, I wouldn't. I'd have made a text file de-duper and merging program in C++, because it's at least 6 orders of magnitude less fucking gay.

Every time I work with anything even associated with VB, I want to fucking blow my brains out...

So... what in the fuck is wrong with that code over there?
>>
>>56272805
>Anyone know what the living shitfuck is wrong with this bit of code?
It's in VB
>>
>>56272805
What is it doing?

What is it supposed to do?

Are you getting any errors?

Are you debugging with breakpoints to check the values of your fields as you step through the code?
>>
How are the job prospects for someone specializing in low-level development, encryption and data security?
>>
File: xt19LRV.png (151KB, 1368x800px) Image search: [Google]
xt19LRV.png
151KB, 1368x800px
Been doing a bit of OpenGL. I got point-segment intersections working, so now I can make cool light beams!

I sent the 3 positions as simple vec2 uniforms, which get turned into quads in the geometry shader, then a distance cutoff and the intersect code in the fragment shader to make the quad look circular and cull anything not in the segment region.

Not much, but it's fun!
>>
>>56272843
Less jobs, but higher-paying.

You'll be fighting boomers for the position, depending on the job.
>>
>>56272814
Yeah, but that doesn't help me fix it.
What is VB saying is wrong?

>What is it doing?
Nothing. It fails to compile

>What is it supposed to do?
Compile and then sort a variable column based on a name in the first row.
(it needs to do more, later, though)

>Are you getting any errors?
Yes, it expects an '=' somewhere.

>Are you debugging with breakpoints to check the values of your fields as you step through the code?
I haven't tried that, but I've tested the message box to output all variables up to this point. It gives the value:
A:A as the range, which works elsewhere in the script, so I can only assume that the range is fine.
>>
>>56272904
oh, sorry, forgot to link:
>>56272830
>>
>>56272865
>Less jobs, but higher-paying.
False, it's less jobs and less paid. Employers are well aware that there are more qualified devs than there are actual jobs, and they exploit this by driving the wages and salaries down.

If you want to make big money, do web dev (and do it well)

Source: I work as an embedded dev and I worked as a web dev in the past.
>>
>>56272904
>somewhere
Where?

Visual Studio will literally highlight the point of failure.
>>
File: 1472208774705.webm (1MB, 720x404px) Image search: [Google]
1472208774705.webm
1MB, 720x404px
>>
>>56272927
This is for Excel.
It's not in VS.

Basically, my client does not particularly want a program to do this thing, so I have 2 options:
de-dupe and merge over 6 THOUSAND records by hand, concatenating each field in each record on duplicates before deleting the row, or write a script I can give them and charge for the time it takes to write the script instead of manually removing duplicates and merging their fields.
>>
File: 1458423871335.jpg (28KB, 450x600px) Image search: [Google]
1458423871335.jpg
28KB, 450x600px
>>56272956
>>
>>56272956
>>56272977
Are you in the wrong thread?

>>56272967
This would be trivial in C#. You could just point a small .EXE at the spreadsheet and it would automatically run the de-dupe over the file/cells/columns you specify. Doesn't matter if it's CSV or actual Excel; .NET has interop libraries.

Unfortunately, I am not very familiar with VB. I'd imagine you could do something like this with DAX instead if you must work within the Excel program.
>>
>>56272925
Shouldn't this be the opposite?
Every Pajeet these days is into web dev, but fewer are the people who go for embedded development and data security.
>>
>>56273018
Fuck.... I'll keep looking into it, then. There's gotta be some gay ass syntax error...
But it is, objectively between
cs.Sort.SortFields.Clear
cs.Sort.SortFields.Add Key:=Range(rangeFinal), _
SortOn:=xlSortOnValues, _
Order:=xlAscending, _
DataOption:=xlSortNormal


That DOES get highlighted...

All the fucking function in this language are utter shit...
>>
>>56272956
omg he looks so ashamed of himself
>>
>>56272348
Some people spend their night watching tv or drinking, others video games or books, he spends it on stackoverflow
>>
>>56272575
That's actually brilliant to use SO to get to know your audience for writing a book.
>>
Any suggested reading for learning Verilog?
>>
>>56272956
Are we discussing Rust?
>>
can someone refresh me on Word types in haskell
whats a word8, a word32, etc
>>
How do I stop wanting to develop video games?
>>
>>56273198
uints
>>
>>56273214
Go try to do it.

That should cure you.
>>
>>56273214
Try to do it and you'll stop
>>
>>56272925
don't convince others about your stupidity...
embedded development is much harder than shitty web development, todays pcs have lots of ram and fast cpus. when developing for embedded systems, you have to do it good, and know exactly what instructions you have to type without bloating all the available space you have. To effectively use 256kb or less of space for the hardware, you have to know what you are doing. not to mention the specifications of each different hardware, what you cannot google.. but on web dev almost everything can be found on stackoverflow, and googling sample codes...

>in b4
>you were a stupid cunt who underestimated the required pay for the job, or did some fucking easy task which obviously pays less than web development.
>>
>>56272362
import functools

Sorry I'm a lazy fuck.
>>
>>56273214
Bullet through the brain should do it.
>>
in hscurses, how do I convert a Char to a Chtype
>>
>>56273328
Good point [spoiler]for another argument[/spoiler]
>>
>>56273354
What argument would that be?
>>
File: IMG_20160826_150959.jpg (72KB, 1334x750px) Image search: [Google]
IMG_20160826_150959.jpg
72KB, 1334x750px
>>56273328
Embeddeds are mostly written in C or even C++ these days. Its not like its all assembly.
>>
>>56272956
>he fell for the open relationship meme
>>
>>56273397
Why would you overload new and delete when you have constructors and destructors? Or is that what he meant?
>>
>>56273340
It seems that ChType can only take 8 bit encodings, so encode your char to utf8 and go byte by byte. Source: http://stackoverflow.com/questions/30198550/extracting-wide-chars-w-attributes-in-ncurses

"char" in C is an 8 bit integer btw (inb4 the standard doesn't say so: be real) not to be confused with Char in haskell which is any Unicode character I believe.
>>
>>56273397
>operator overloading: none
This makes no sense to me

>templates: none
What about templates only instantiated once?
>>
>>56273474
They overload new and delete because they have a custom allocation scheme.

Constructors only get called after the object is allocated, they get called inside your new.
>>
>>56273504
>What about templates only instantiated once?
why use a template then?

>>56273504
>This makes no sense to me
I guess in realtime environments you don't want any hidden costs of method calls.
>>
>>56273534
>why use a template then?
So you can change it

>I guess in realtime environments you don't want any hidden costs of method calls.
inlining?
or just don't define your operators as method calls?
>>
>>56273504
>This makes no sense to me
Operator overloading, not parameter overloading.
>What about templates only instantiated once?
Then what's the point of using templates?
>>
>>56273549
>not parameter overloading
What do you mean by that? And what's wrong with operator overloading?

>Then what's the point of using templates?
So you can change it
>>
>>56273504
>This makes no sense to me
Operator overloading can be deceptive. It's better to be explicit and use functions like Vector.DotMultiplication than overloading *. Sure if you know that * is overloaded to dot multiplication then vector1 * vector2 makes perfect sense, but that requires you have previous knowledge about the codebase. Using a function with a descriptive name prevents that. Also vector1 * vector2 could mean any number of things that would all be equally natural depending on context. See: https://en.wikipedia.org/wiki/Multiplication_of_vectors

>What about templates only instantiated once?
Why would you do that? Isn't the point of templates to give generic reusability? Just copy paste the template into the that one place.

>>56273518
Ah of course, that makes sense.
>>
>>56273490
>encode to utf8 and go byte by byte
sorry, can you help me, how do I do that?
>>
>>56273490
>inb4 the standard doesn't say so: be real
Non 8-bit char implementations do exist though. Making your code pointlessly non-standard is retarded.
>>
>>56273542
>So you can change it
If you only instantiate a template once you can just as well do a typedef and then change that.

I believe the main reason they disallow templates is because the code suddenly has to account for all types that exist.
>>
>>56273577
string_to_byte_array(encdo_utf8(string))
>>
>>56273568
>operator overloading can be deceptive
If you're working with someone else's codebase maybe, I wouldn't use * for dot product

>why would you do that
So you can change it

>>56273593
>I believe the main reason they disallow templates is because the code suddenly has to account for all types that exist.
It doesn't though, I would have assumed the reason is because of code duplication. i.e.
myfunction<int>, myfunction<float>, myfunction<double> is 3x as much code
>>
>>56273589
>Doing everything hard for yourself because there exists few obscure platforms that you will never even use
>>
>>56273603
in haskell
>>
>>56273618
This.

Code for x86_64, >=SSE3, >=2 cores, 4+ GB RAM, >=Win7/Kernel 3.x
The rest can go fuck itself.
>>
>>56273577
Check Data.ByteString.UTF8 (something like that), encode some String (given that one single Char can result in more than one byte it's not fundamentally different), then map over the bytes and fromIntegral them to ChType aka Word64. You should get a Ncurses string that contains your string's character and no markup. Talking out of my generic Haskell knowledge just so you know.
>>
>>56273612
>myfunction<int>, myfunction<float>, myfunction<double>
http://www.gotw.ca/publications/mill17.htm
>>
>>56273490
Why are char types so silly?
Especially since most encoding are either variable is size, not portable or just a massive waste of space.

Text should be treated as blobs. char types are confusing.

First thing I do in a C project is typedef my char to int8.
>>
>>56273568
But * isn't the mathematical symbol for a dot multiplication.
>>
>>56273713
neither is .dot(
>>
>>56273665
> >=SSE3
x86_64 implies a minimum of SSE2, so just use that.
> >=Kernel 3.x
There are a lot of computers (mission critical ones that can't be updated) that are still on 2.6. And honestly that's not a whole lot less.
> >=Win7
How different is Vista? I know no one really uses it, but it's NT6 like Win7 so why the hell not.
>>
>>56273214

1. It's fucking hard.
2. No really, it's insanely hard, you have to know a lot about a lot of topics.
3. Good luck finding a job as game dev unless you are willing to work an unreal (no pun intended) amount of time.
>>
>>56273665
>only extremes of both end are choices and there's nothing in between
>>
>>56273715
True, but using * is misleading, using .dot isn't.

* Should only be used as Vector * Scalar
Since that makes sense mathematically.

Operating overloading becomes especially more readable when you have nested operations

matrix * matrix * matrix...
Or
matrix.multiply(matrix.multiply(matrix.multyply(...)))
>>
I have a Python script that runs multiple times a second nonstop and updates a global variable.

Perhaps with a secondary script, do you know a way that I can accurately print what that global variable was five seconds ago? I want it to continuously print out what the value was five seconds ago as it is being updated right now.

I'm not sure how to approach this. Does anybody have any ideas?
>>
>>56273612
>If you're working with someone else's codebase maybe, I wouldn't use * for dot product
That's exactly the thing. Maybe I would use * for dot product. And maybe we're both working on that same NASA codebase. It's better to just avoid the potential for confusion all together. All it costs you is typing out .DotProduct(); instead of *.
>>
Simple palindrome checking function in JS, stil doesn't work for TRUE, ... only gives FALSE

function palindrome(str) {
var strRev = "";
var i = str.length - 1;
while (i >= 0) {
strRev += str[i--];
}
if (strRev == str) return true;
else return false;

}



palindrome("eye");



I tried many things, this one with the i-- was suggested by an anon, still doesn't work
>>
>>56274330
That's weird

if I put it in jsbin.com it works

but on FreeCodEcamp it doesn't pass
>>
>>56274330
var str = "palindromemordnilap";

var isPal = true;
for (var i = 0; i < str.length / 2; i++) {
if (str[i] !== str[str.length - 1 - i])
isPal = false;
}

isPal; // True
>>
>>56274427
thanks

can you tell me what was wrong with mine though? if you see anything wrong with it?

thanks
>>
>>56274330
>>56274455
Maybe it has something to do with a value vs. reference comparison on your strings.

I'm not certain about Javascript, but "==" is a reference comparison on non-value types, so you're asking if those are literally the same thing, rather than equivalent strings.

Does Javascript have a
.Equals()
-like method?
>>
File: 1468683408746.jpg (55KB, 800x530px) Image search: [Google]
1468683408746.jpg
55KB, 800x530px
anyone bored to check whats wrong with my code? im coding some game and im trying to implement fps lock, but shits not working

gloabal variables
    RakNet::Time delta_time_old = 0; //64bit, milliseconds
RakNet::Time delta_time_new = 0;
float delta_time_ = 0 // seconds
float fps_timer_ = 0;
int fps_counter_ = 0;
float average_fps_ = 0; // updated once per second
float fps_lock_ = 0; // variable provided by user ie. 60



inside loop
while(1)
{
d->delta_time_old = d->delta_time_new;
d->delta_time_new = RakNet::GetTime();
RakNet::Time dt = d->delta_time_new - d->delta_time_old;
d->delta_time_ = (float)dt / 1000.f;

d->fps_timer_ += d->delta_time_;
if(d->fps_timer_ >= 1.f)
{
d->average_fps_ = d->fps_counter_ / d->fps_timer_;
d->fps_timer_ = 0;
d->fps_counter_ = 0;
}
d->fps_counter_++;

if(d->fps_lock_ > 0)
{
uint64_t frame_max_time = 1000 / d->fps_lock_;
if(dt < frame_max_time)
{
uint64_t wait_time = frame_max_time - dt;
boost::this_thread::sleep_for(boost::chrono::milliseconds(wait_time));
}

}

update();
draw();
}


i get weird results, when im locking at
1 fps, i get 2
10 -> 20
30 -> 40
60 -> 80
100 -> 80
uncapped -> 200000
>>
>>56269550
python has done more AI than lisp

lisp today is only alive in clojure, aka pajeet tier
>>
>>56274330
>>56274427
A simpler method would be
const isPal = word =>
word === word.split("").reverse().join("")
>>
>>56274330
Try replacing "==" with "===".
>>
>>56274455
>>56274539
Yeah this could be the problem, try strRev === str.

>>56274561
Way worse performance though. Then again if that was a concern you wouldn't be using Javascript.
>>
>>56274539
>>56274597
>>56274580
thanks guys ! <3
>>
going to implement the product, quotient, and chain rule in ti basic today lads
>>
File: 1460404725900-0.png (57KB, 200x174px) Image search: [Google]
1460404725900-0.png
57KB, 200x174px
>>56274638
Gambatte ne!
>>
I bet the janny is fishing for a pay raise with all this hard, hard work

like a hawk this one
>>
Tell me to code something in Python...and I'll give it my best shot.
>>
>>56275234
Permutations of an array
>>
>>56275408
import itertools as it

def array_perms(a):
return list(it.permutations(a))
>>
>>56275234
reverse a string in 3 lines or less
>>
>>56275468
def reverse(s):
return s[::-1]
>>
>>56275501
reverse a string in one line
>>
>>56275234
Extract data from any public API and store it in a local database of your choosing.
>>
>>56275459
Pretty good, lets move on to some harder ones

median of 2 sorted arrays (when merged)
>>
>>56275518

print ((input('Enter string you want reversed here: '))[::-1])
>>
File: lol.png (18KB, 624x291px) Image search: [Google]
lol.png
18KB, 624x291px
>>56275527

I actually already did this with the 4chan API and /soc/ as a little experiment
>>
>>56275562
yeah I thought that was a bit easy

try this:

without using any operators, preform a matrix multiplication on a 2d list of unspecified dimensions
>>
>>56275592
>>56275562
rather two 2d lists, I mean
>>
>>56275532
>>56275468
>>56275518
>>56275592
What's with this trivial CS101 bullshit?

Recommend something worthwhile.
>>
>>56275617
Solve P = NP. In python.
>>
>>56275234
video games
>>
>>56275635
That's trivial, too.
>>
>>56275641
>>56275617
ok write something which gives me the distance between any two inputted complex functions, like y=x^2 and y=x^3
that should be a fair bit of difficulty
>>
>>56275685
I meant to say area between the two curves
>>
there's a new thread btw
>>56275136
>>56275136
>>56275136
>>
>>56275698

basic integration?
>>
>>56275709
yes

start with breaking it up by intersections, solve for integral from y=0, subtract the furthest part from the closest
Thread posts: 335
Thread images: 50


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