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

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

Thread replies: 255
Thread images: 23
File: steinsgate-02-ruka-blush.jpg (53 KB, 1280x720) Image search: [Google]
steinsgate-02-ruka-blush.jpg
53 KB, 1280x720
You faggots didn't accomplish anything in the last thread. Want to try again?
>>
Nice projects to learn Android programming ?
>>
>>53665347
Yes and thank you
to replace it I can just set a new definition and it will automatically override it, right?
>>
>>53665493
Is OCaml a meme?
>>
>>53665547
Snapchat
>>
>>53665620
Not a meme, just not taken seriously.
>>
>>53665620
Yes, but not as much as Python or Java
>>
actual thread

>>53665401
>>
>>53665563
That depends on how WordDef is implemented, but probably. Though it might be better to just use a dictionary (the data structure) instead of an array.
>>
>>53665676
>made before the bump limit
Kill yourself.
>>
>>53665676
>thread that is going to be deleted
>>
hello lads
>>
Can you guys complete this function?
boolean isOdd(int n) {
// code goes here
}

Just fill in the function.
>>
>>53665726
keep believing that, idiot

if any thread gets deleted it's going to be this one
>>
>>53665824
Past experience proves you wrong. Remember the premature mumin, premature trap and mature trap thread?
>>
>>53665820
return n == 1 || n == 3 || n == 5 || n == 7 || n == 9 /* however many you need */;

It's the fastest way to do it I swear.
>>
>>53665824
This one was posted after the bump limit. Shut the fuck up.
>>
>>53665820

if ( i == 0 ) return false;
if ( i == 1 ) return true;
if ( i == 2 ) return false;
if ( i == 3 ) return true;
...


e-z p-z
>>
>>53665820
iseven = require('is-even')
not = require('not')

module.exports = not(iseven)
>>
>>53665820
boolean isOdd(int n) {
if (abstractIsOddFactoryBean.getInstance().newIsOdd().isOdd(n) == true) {
return true;
} else if (abstractIsOddFactoryBean.getInstance().newIsOdd().isOdd(n) == false) {
return false
}
}
>>
>>53665820
Easier than isEven

boolean isOdd(int n){
return n&1;
}
>>
>>53665896
Aren't bitwise operators with signed integers undefined?
>>
>>53665885
>!(2 % 2)
>!(0)
>1
>2 is odd

>>53665896
wrong
>>
>>53665820
import Data.Bool
import Data.Maybe
import Data.Nat

mutual
data Even : Nat → Set where
evenZero : even zero
evenSuc : odd m → even (suc m)

data Odd : Nat → Set where
oddSuc : even m → odd (suc m)

mutual
isEven : (m : Nat) → Maybe (Even m)
isEven zero = Just evenZero
isEven (suc m) = map evenSuc (isOdd m)

isOdd : (m : Nat) → Maybe (Odd m)
isOdd zero = Nothing
isOdd (suc m) = map oddSuc (isEven m)
>>
>>53665875
; iseven = require('is-even')
; not = require('not')

; module.exports = not(iseven)

FTFY
>>
>>53665905
No.
>>
File: 18211.png (98 KB, 400x300) Image search: [Google]
18211.png
98 KB, 400x300
>>53665919
>>
>>53665905
not sure. It works in c++. If java does it differently then Java is shit.
>>
>>53665620
it's pretty comfy :3
>>53665919
even comfier~
>>
>>53665820
return !isEven(int n);
>>
>>53665911
Actually it's right.
>>
>>53665936
>It works in c++
implementation-defined
>>
>>53665952
Actually it's not. See >>53665905
>>
>>53665933
not sure if 9gag or just reddit
>>
>>53665875
function lookup (table, key, callback, _this) {
if (key in table)
callback.call(_this, null,
{ key: key,
value: table[key]
table: table });
else
callback.call(_this,
new Error("The key could not be found");
}

module.exports = function (x, callback, _this) {
if (x === undefined || x === null ||
arguments.length === 0) {
callback.call(_this, new Error("invalid number of arguments"));
}
else if ((typeof x) !== "number") {
callback.call(_this, new Error("invalid argument"));
}
else {
var oddNumbers = {};
for (var i = 0; i < 10000; i++) {
if (i % 2 == 1) {
oddNumbers[i] = true;
}
}

lookup(oddNumbers, x, function (err, res) {
if (err)
callback(_this, null, false);
else
callback(_this, null, true);
});
}
};
>>
>>53665966
it's probably implementation-defined for C/C++ (google/stackoverflow is fucking shit) and in java it's perfectly defined you fucking retard, just that his code doesn't work because it should be (i & 1) != 0
>>
>>53665919
import Data.Bool
import Data.Maybe
import Data.Nat

mutual
data Even : Nat → Set where
even-zero : Even zero
even-suc : Odd m → Even (suc m)

data Odd : Nat → Set where
odd-suc : Even m → Odd (suc m)

mutual
isEven : (m : Nat) → Maybe (Even m)
isEven zero = Just even-zero
isEven (suc m) = map even-suc (isOdd m)

isOdd : (m : Nat) → Maybe (Odd m)
isOdd zero = Nothing
isOdd (suc m) = map odd-suc (isEven m)

Fixed and slightly improved.
>>
>>53665960
I'm pretty sure it's only implementation defined if the sign bit is involved.
>>
>>53665966
IF he is right, then do it this way

boolean isOdd(int n){
return (n&0b1)&0b1;
}


This isolates the LSB. If this doesn't work then how the fuck does java even work.
>>
File: too easy for me.png (7 KB, 274x444) Image search: [Google]
too easy for me.png
7 KB, 274x444
>>53665820
Easy :)
>>
>>53665976
>writing more than 5 lines per module
>in node.js
try moving out the logic into a few more npm packages and then we can talk, anon
>>
>>53665960
>>53665966
>>53665984
>>53665993
Don't talk if you don't know. You are wrong.
>>
File: OP phag.gif (6 KB, 427x320) Image search: [Google]
OP phag.gif
6 KB, 427x320
non-retarded thread:

>>53665401
>>53665401
>>53665401
>>
>>53665820
boolean isOdd(int n) {
return !isEven(n);
}

boolean isEven(int n) {
return !isOdd(n);
}

Prove me wrong.
>>
>>53666000
Stop spamming, faggot. Nobody likes your premature troll thread.
>>
>>53665995
FUCKING RETARDED C SPERG MEME SHITTER YOU CRITICIZE JAVA BUT YOU DON'T HAVE THE SLIGHTEST CLUE ABOUT IT OR TYPE SAFETY IN GENERAL
>>
>>53666009
FUCKING RETARD FUCKING KILL YOURSELF LOOK WHO'S SPAMMING >>53665639 >>53665947
>>
>>53665976
>if (i % 2 == 1)

wrong

>>53665984
bitwise is wrong for signed.

>>53665995
>java

This isn't any particular language
>>
>>53666029
>bitwise is wrong for signed.
not for two's-complement ints

>This isn't any particular language
>boolean
ok lad
>>
>>53666028
>hurrr duuurrr some two different people let others know of the actual thread so I will behave like an underage faggot :))
>>
>>53666029
>boolean

That's a java keyword

>>53666011
>>53666028
You're not being very subtle about how butthurt you art
>>
>>53666043
>not for two's-complement ints

That's your assumption, not a given.

>>boolean
>ok lad

Yes, the concept of true/false is unique to java.
>>
>>53666029
>bitwise is wrong for signed.
>>53666043
>not for two's-complement ints
Wrong
>>
>>53666045
this isn't the actual thread, IF one of the threads get deleted before they die naturally it's pretty likely that it's going to be this one because this is the redundant duplicate thread that was posted after >>53665401
>>
>>53666007
can't prove shit, your procedures aren't total
>>
>>53665998
You're right. I should have put the lookup() into a separate NPM module, and also the argument checking.
var lookup = require("listlookup"),
checknum = require("checknum"),
generateOdd = require("generate-odd");

module.exports = function (x, callback, _this) {
checknum(x, function (err) {
if (err)
callback.call(_this, err);
else
generateOdd(1000, function (err, list) {
if (err)
callback.call(_this, err);
else
lookup(list, x, function (err, result) {
if (err)
callback.call(_this, null, false);
else
callback.call(_this, null, true);
});
});
});
};
>>
>>53665820
bool isOdd (int n) {
if(n%2 != 0) {
return false;
}else {
return true;
}
}
>>
>>53666069
Your thread was premature and filled with your shitposts. This one has actual programming discussion.
We talked about this.
>>
>>53666069
1. This has more replies
2. This was clearly posted after the bump limit
3. Your damage control is shit tier
9001. kill yourself
>>
if (n % 2 == 0 || n%2!=0)
{
if(n==0)
{
return(true);
}
else if(n==1)
{
return(true);
}
else if(n==2)
{
return(false);
}
else if(n==3)
{
return(false);
}
else
{
isodd(n+2);
}
>>
File: 1452320376169.jpg (33 KB, 307x272) Image search: [Google]
1452320376169.jpg
33 KB, 307x272
>>53666082
>>
>>53666082
ur killin me femanon
>>
>>53665820
boolean isOdd(int n) {
return ( (n & 0x01)==0x01 )
}
>>
>>53666082
delete this
>>
>>53666029
>wrong
It passed my Unit Test (tm), it must be correct!
>>
>>53665820
num =>
num % 2
>>
>>53666101
wrong
>>
>>53666101
Just a tip, use binary instead of hex

n&0b1 == 0b1
>>
>>53666123
non-standard
>>
>>53666135
Says fucking who
>>
>>53665820
bool isOdd(int n) {
int i = 0;
for(i=0;i<=n;i++) {
if(i == n) {
if(i%2 ==0) {
return true;
}
else {
return false;
}
}
}
}
>>
>>53666165
my dad works for oracle (indian branch)
>>
>>53666176
>implying poo-in-loo would be working with binary
>>
>>53666185
that's true

binary only has 0s and 1s, not number 2 wahey!
>>
>>53666185
>implying poo-in-loo is considered human
>>
>>53666175
these fucking memes are golden I swear to god. That else statement is the icing on the cake
>>
>>53666175
>implementing isEven
>>
>>53666213
>Even
>Odd
stop oppressing me with your whites males's mathematics you racist and sexist shitlord
>>
>>53666237
>mfw boolean can only be true or false
>no room for non-binary values or boolean-fluid values
>>
>>53666237
genderfluid is literally the same thing as binaryfluid

it doesn't exist
>>
>>53666276
you're raping me!!!
>>
Im practicing 2d arrays in c. Yeah im a noob
>>
>>53666302
keep it on, C isn't that difficult but you need to know what you do or you'l fuck up pretty fast
>>
>>53666302
After you're done, do that shit with double pointers and delete it afterwards.
>>
My parser causes stack overflow when I have a function nested ~500 times. Is there anything I can do?
>>
<code>
if (n % 2 == 0 || n%2!=0)
{
if(n==0)
{
return(true);
}
else if(n==1)
{
return(true);
}
else if(n==2)
{
return(false);
}
else if(n==3)
{
return(false);
}
else
{
isodd(n+2);
}
</code>
>>
>>53666633
Add the requirement that people don't nest their functions 500 times.
>>
>>53666633
err... Preprocessor?
>>
>>53666705
The test suite for verifying correctness of parsers for this particular language has nesting up to 1000 times.
>>
>>53666633
Transform non-tail recursion into a stack data structure ; you have more heap space than stack space.
That sounds like a bitch to actually implement but it would do the job.
>>
>>53666746
Try replace the recursion with iteration and an explicit stack then.
>>
>>53665493
Where is that anime girl from?
>>
>>53666754
>>53666813
Well, I guess I'll do that.
>>
>>53666862
>filename
>>
>>53666862
>girl
>>
>>53666922
She is actually a girl if you played the VN or watched the anime.
>>
>>53666931
It's a dude, except for that one timeline.
>>
>>53666941
the only acceptable timeline.
>>
>>53666931
>>
>>53667059
I want to lick up those tears.
>>
>>53667073
I want to lick up those feet.
>>
Spent most of today dicking around on my work computer, setting up an ultra-ghetto dev environment. Now I can write and compile C# programs despite not having VS installed. This basically just consists of notepad and csc.exe, but I guess from here I can build a better editor or something.

Wish me luck.
>>
>>53667208
>notepad
>windows
>C#
>>
>>53667142
cute
>>
>>53667142
You know how people learn to draw by tracing anime?
This is what happens.
>>
>>53667223
>(You)
>>
Is windows really frowned upon
>>
>>53667223
Alternatively, I could build and load C# assemblies in Powershell for use in scripts. Having found the compiler at least lets me create standalone executables, though
>>
>>53667208
It took you all day to compile C# outside of VS?

You're employed?
>>
>>53667324
depends. In a poo-in-loo job, no. In a hardware job, yes.
>>
This dpt is too shitposty, so I'm heading over to the non-weeb one
>>
>>53667336
What a load of crap. Windows is prefectly fine.
>>
>>53665493
Today I'm contributing to lo/g/os
>>
>>53667142
that's a terrible drawing
>>
>>53667333
Nah, getting set up to compile only took a couple minutes. The day was spent fucking around with it after, and trying to see what I could get away with not having admin
>>
Is it possible to make an integer power function without using extra memory in the x86 architeture? I tried that, but I coudn't test it.

pow proc x:DWORD, y:DWORD
push ebx
push edi
push esi
mov eax,x
mov ecx,y
xor ebx, ebx
inc ebx
mainLoop:
shr ecx,1
jb noMultiplication
xchg eax, ebx
mul ebx
xchg eax, ebx
noMultiplication:
cdq
mul eax
test ecx,ecx
jnz mainLoop
mov eax, ebx
pop esi
pop edi
pop ebx
ret
pow endp
>>
>>53667324
not in real life, but in /dpt/, literally two thirds are linux-using neckbeards, at least according to a strawpoll that we did
>>
Java Question:

What is the difference between List<?> and List<T>
>>
File: ruka.png (66 KB, 582x485) Image search: [Google]
ruka.png
66 KB, 582x485
>>53667142
I want to lick up his cum.
>>
>>53667425
One is written with a question mark and the other with a capital T.
>>
>>53667436
kill yourself samefag trap FAG
>>
>>53667423
I think it boils down to /g/ hating productivity, hence the hate for Windows, languages like C# and Java, and basically anything that could lead to employment or usefulness.

It's a fun place.
>>
>>53666922
>>53666941
Not getting the Luka ending
>>53667436
>ruka
Absolutely disgusting
>>
>>53667436
link to mangu?
>>
File: ruka condom.jpg (250 KB, 700x700) Image search: [Google]
ruka condom.jpg
250 KB, 700x700
>>53667460
Yes, Ruka.
>>53667464
http://exhentai.org/g/546089/9071811507/
>>
>>53667455
yup
>>
is this alright for a popAll function for an array stack? top is the next free spot, and also the total number of elements in the array

    public void popAll() {    
for(int i = 0; i < top; i++){
stack[i] = null;
}
top = 0;
}
>>
>>53667208

But notepad and csc.exe are installed on Windows out of the box. At least get something like notepad++ portable...
>>
>>53667618
>for(int i = 0; i < top; i++){
> stack[i] = null;
> }
Why? Looks useless.
>>
>>53667618
Is there a reason you are wasting time clearing the now unused stack entries?
>>
>>53667724
is it not poor form to just set top to 0 and leave a bunch of data left in there?
>>
I would really like an SICP tier(not too easy, but still an intro) book but for systems. I would like to learn how those are programmed and how to program those.

There is the mit ocw one, but they only have the second part online, you have to buy the first part, so I will use the mit courses only when I have a little bit (or a lot) of knoweledge already.
>>
>>53667742
well, it could prevent me from not getting an error when i should. ie you pop all, but then something goes wrong, but instead of getting an error because of trying to access null you just get old data
>>
>>53667745
nope
>>
Hey guys I'm learning Java and was thinking the best way is to learn about the core java principles, piece by piece. That is: Variables, Methods, Classes, etc.

I was wondering if there is a list somewhere someone can link that provides every single topic regarding the core of Java.

My goal right now is to learn a new concept every single day and once I'm done, begin creating a program every day and eventually jumping the ship to larger ones.
>>
>>53667392
>Windows is prefectly fine
Non-broken symlinks, file paths longer than 255 characters, cross-platform build environments, sane dependency management and actually decent disk I/O performance is reason enough to frown upon Windows.
>>
Working with C. This fucking linked list is being an absolute faggot to me. It keeps printing out the first line read from an input file instead of printing out the rest of the data I need. Love you C.
>>
>>53667791
just go to college, i know some fine jewish gentlemen who have ASTOUNDING rates on student loans
>>
>>53667874
>using linked lists
use a circular buffer you fucking pleb
>>
>>53667806
all that stuff doesn't matter
>>
>>53667874
If it's for a school assignment, send this to your teachers https://www.youtube.com/watch?v=YQs6IC-vgmo
>>
>>53667889
fuck you faggot
>>
>>53667902
Can't, required for this project (yay uni)
>>
I want to compress with a password and then access certain files later in the program

How can i compress and extract files? I'm on Visual C++ if it matters, i don't want to use meme libraries or deprecated stuff so i'm asking
>>
>>53667915
Sure thing, faggot.
>>
>>53667937
he's doing what people like me call a shit test. you have to assert your dominance
>>
>>53667970
Well you sure as shit aren't gonna do it with the std libraries. Easily anyways.
>>
>>53668022
External libraries of course but not sure what to use that's why i'm asking
>>
>>53667971
You can frown on it from your corner in the basement, then, while the rest of the world gets on just fine running Windows for their jobs.
>>
>>53668043
linux is vastly more common than windows for actual important things
>>
>try to set up desktop pc to transmit Bluetooth data to test my android app
>motherfucking matlab can't see the device
>keeps giving me null exception


anyone know a good way of setting up Bluetooth data transmission on C#, python or C?
>>
>>53668043
Yeah in IT jobs maybe. I'm in the hardware/embedded systems market and every job I look they require experience in Linux.
>>
>>53665820
 public static bool isOdd(int n)
{
string num = n.ToString();
bool odd = false;
for (int i = 0; i < num.Length; i++)
{
if (i == num.Length - 1)
{
char c = num[i];
switch (c)
{
case '0':
odd = false;
break;
case '1':
odd = true;
break;
case '2':
odd = false;
break;
case '3':
odd = true;
break;
case '4':
odd = false;
break;
case '5':
odd = true;
break;
case '6':
odd = false;
break;
case '7':
odd = true;
break;
case '8':
odd = false;
break;
case '9':
odd = true;
break;
default:
throw new Exception("Something went wrong");
break;
}
}
}
return odd;
}
>>
>>53668142
>hardware/embedded
AKA the outsourced job market
>>
>>53665771
Lmao kill yourself. Here's your (you)
>>
>>53668043
Sure thing, faggot.
>>
>>53667933

Anon, touting the disadvantages of linked lists is not likely to fly in a data structures class. A good professor would likely have already gone over them in the lecture, but would nonetheless point out that you still have to do l create them first the assignment, because if the university graduates a computer science student who can't implement a fucking linked list, it'll be terrible for their reputation, and they'll likely lose accreditation.
>>
>>53668168
lolwut
>>
>>53668094
l0l
>>
>>53668183
Err data structures, I learned about linked lists in an Intro to programming class.
>>
Is the part of the thread, where we pretend to be experts on topics we have no clue about?
>>
>>53668168
Hardware jobs don't get outsourced. They need someone who actually knows what they're doing.
>>
File: 1360901996387.jpg (378 KB, 580x864) Image search: [Google]
1360901996387.jpg
378 KB, 580x864
>>53668095

a-anyone?
>>
>>53668250
Get the fuck out of here, we're busy with our OS dick waving and petty offtopic bullshit.

Go ask your real questions in a classroom.
>>
>>53667258
It's bothering me how if you look very closely the artwork is pretty good but if you look at it at a whole it's pretty fucking bad
>>
I can't believe they killed tay
>>
>>53668221
Yeah man, they would never outsource a job to some know-nothing Indian just to save a buck. This has literally never happened.
>>
>>53668169

u first fagt
>>
>>53668294
Lel oh well. I'm not worried about it. With a double major I have a shit load of jobs at my disposal.
>>
>>53668270

well fuck where's a good place to ask online?
>>
Java is the best programming language you are a shitty programmer if you disagree. All hail Java King of /dpt/
>>
>>53668328
stackoverflow
>>
>>53668341
nice

meme

.

jpg

j
a
v
a

i
s

a

s
h
i
t

l
a
n
g
u
a
g
e
>>
>>53668328
Freenode IRC has some good channels for #csharp and #python.

Just stay away from ##c, it's poisonous.
>>
>>53668361
Java is better than whatever shit language you use because YOUR SHIT you are all shit and any java programmer can out program you with one hand because of how superior Java is only the brightest understand it
>>
>>53668386
>your shit

You type like an Indian

Just because you understand it doesn't automatically make it good
>>
>>53668400
Hi this Pajeet I can program you for $5 dollars
>>
>>53668165
i genuinely can't tell if you're joking or not
>>
>>53668424
>realistically a one line return statement function
>can't tell if joking

c'mon
>>
>>53668449
doesn't deal with negatives faggot
maybe should've taken unsigned inte-
AHAHAHAHAHAHAHA
>>
>>53665820
Glorious Java programmer here I'll solve this


public static boolean isOdd(BigInteger n)
{

if( n.divides(2) == 0 )
{
return false;
}
else
{
return true;
}
}

>>
>>53668475
>braces strewn all over the place
>else statement when returning something
>function instead of modulus
>modulus instead of bitwise
>BigInteger

Looks like a java programmer to me
>>
>>53668475
> == 0
don't you mean === new Integer(0)
>>
File: machine_learning.jpg (171 KB, 1416x756) Image search: [Google]
machine_learning.jpg
171 KB, 1416x756
I want to get into machine learning and AI shit.
I know C++ and Python.
Where do I start?
>>
>>53668494
>>53668497
GLORIOUS Java master race only uses Big Integer because it's a real man's primitive data type
>>
>>53665820
all these troll replies
if (n%2 == 0){ return true;} // return true
else if (n%2 != 0{ return false;} //return false
else return false; // an error occured

simple
>>
>>53668517
>not using Haskell where you can do the same but it isn't extremely verbose
>and it's also generic, so it works on fixed integers too
Why do people still insist that OOP is a good thing?
>>
>>53668531
>>>>>>>FUCKING ELSE

stop doing this pls
>>
>>53668531
>an error occured
That else condition literally will never be met, no error in the world would cause it to go there
>>
>>53668540
Simple OOP Java is the best in large real manly men applications with 15,000 lines of codes to organize your code
>>
>>53668540
>int = 0 | int + 1
>haskell programmers think this is new
>>
>>53668449
my buddy does java professionally and every now and then he'll show me some scary fucking shit his coworkers do, man, i just don't know anymore

one of them set up a bunch of horrible shit for a date-time function, something like
#define MS_PER SECOND 1000
#define SECONDS_PER_MINUTE 60
#define MINUTES_PER_HOUR 60
#define HOURS_PER_DAY 24
#define DAYS_PER_YEAR 365


etc. instead of just using any number of standard fucking libraries
>>
>>53668589
gay baby retard programmer here, is it better to #define constants or declare constant global variables
>>
>>53668566
You mean "nat"?

>implying I said Haskell invented natural numbers
>implying I was talking about natural numbers, not Integers which are much more efficient
>>

public abstract class chair
{
public Chair(){
String color = "";
int legs = 5;
int buttons = 3;

}

}

public class carChair
{
Chair chair = new Chair(FactoryBeanReset);

}

public class TestChair
{
carChair car = new carChair();
sout(car);

}

>>
>>53668614
>more efficient
You can't even Haskell properly
>>
>>53668612
Literally neither

BUT preprocessors are WAY better than globals
>>
>>53668638
>neither
then how? please humor me im a gay baby
>>
>>53665820
typedef enum { false, true } bool;

bool isOdd(int n) {
return n & 1 == 1
}
>>
>>53668531
>implementing isEven
>>
File: 1374796030634.jpg (58 KB, 600x595) Image search: [Google]
1374796030634.jpg
58 KB, 600x595
>>53668589
>>
>>53668650
Or you could not be a retard and #include <stdbool.h>
>>
>>53668612
It depends on the scope.
#define is only used by the precompiler and is limited to the scope of a single file.
static globals can be used from outside the scope of the file (if not private), but should only be accessible if absolutely required.
>>
>>53668650
wrong
>>
>>53668659
My toaster doesn't support C99 compilers.
>>
{code]

public static abstract final int int swap(int num1, int num2)
{
int temp = num1;
num1 = num2;
num2 = temp;

return num1 && num2;
}
[/code]
>>
>>53668494
You're a fucking idiot if you think bitwise is a good choice
>>
Should I try D or Rust?
>>
>>53668659
treeshaking is unreliable in C, you have to define it yourself for good performance. however, you should extract that one line of code into its own header (notstdbool.h) and then dynamically load that at runtime. be sure to put it up on your favorite distro's package repo
>>
>>53668689
Why not try both?
>>
File: 1456078660633.webm (3 MB, 1024x768) Image search: [Google]
1456078660633.webm
3 MB, 1024x768
You guys should be able to solve this:

int meaningOfLife() {
// todo
}
>>
>>53668689
D
>>
>>53668689
Rust.
D is completely dead at this point, but Rust still has a chance.
>>
>>53668659
>C99

Uncultured swine
>>
File: 1425318106132-2.png (641 KB, 1000x801) Image search: [Google]
1425318106132-2.png
641 KB, 1000x801
Anyone have that programming challenge image?

I just got a job at a SV company, working on a NLP engine in C/C++. Only problem is, I know almost nothing about C++.

Just need some practice. Thanks
>>
>>53668689
Both, but Rust has a better chance of being adopted for more projects.
>>
>>53668701
return 0;
>>
File: 1450934901245.png (302 KB, 1920x1080) Image search: [Google]
1450934901245.png
302 KB, 1920x1080
>>53668711
learncpp.com
>>
>>53668711
http://images.lmgtfy.com/?q=programming+challenge+4chan
>>
>>53668709
>Not using C11
ayy lmao
>>
Consider the following:
public class Fighter()
{
int str = 5;
Attack atk = new Attack();
}

public class Attack()
{
public int calculateDamage()
{
int temp;
. . .
//code here
. . .
return temp;
}
}

Is there a way for calculateDamage to access variables in the Fighter class without having calculateDamage including parameters? How would I go about getting the str variable from Fighter without having calculateDamage() become calculateDamage(int strength)?
>>
>>53668701
void meaning_of_life()
{
return;
}
>>
> all the major players in the infrastructure realm are writing their shit in Go (Docker, ELK stack, half the shit Hashicorp does, etc)
> /g/: "meme language go"

Will /dpt/ every graduate beyond CS101 topics?
>>
>>53668701
>implying meaningOfLife isn't void return type
>>
>>53668711
Here's some fun practice anon.

Write this C++ code in C.
Make all the classes using structs and enable dynamic polymorphism by creating your own vtables.

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

class Unary_Function {
private:
int lower_bound;
int upper_bound;
public:
Unary_Function(int lb, int ub) : lower_bound(lb), upper_bound(ub) {};
virtual double value_at(double x) = 0;
virtual double negative_value_at(double x) {
return -value_at(x);
}
void tabulate() {
for(int x = lower_bound; x <= upper_bound; x++) {
printf("f(%d)=%lf\n", x, value_at(x));
}
};
static bool same_functions_for_ints(Unary_Function *f1, Unary_Function *f2, double tolerance) {
if(f1->lower_bound != f2->lower_bound) return false;
if(f1->upper_bound != f2->upper_bound) return false;
for(int x = f1->lower_bound; x <= f1->upper_bound; x++) {
double delta = f1->value_at(x) - f2->value_at(x);
if(delta < 0) delta = -delta;
if(delta > tolerance) return false;
}
return true;
};
};

class Square : public Unary_Function {
public:
Square(int lb, int ub) : Unary_Function(lb, ub) {};
virtual double value_at(double x) {
return x*x;
};
};

class Linear : public Unary_Function {
private:
double a;
double b;
public:
Linear(int lb, int ub, double a_coef, double b_coef) : Unary_Function(lb, ub), a(a_coef), b(b_coef) {};
virtual double value_at(double x) {
return a*x + b;
};
};

int main() {
Unary_Function *f1 = new Square(-2, 2);
f1->tabulate();
Unary_Function *f2 = new Linear(-2, 2, 5, -2);
f2->tabulate();
printf("f1==f2: %s\n", Unary_Function::same_functions_for_ints(f1, f2, 1E-6) ? "DA" : "NE");
printf("neg_val f2(1) = %lf\n", f2->negative_value_at(1.0));
delete f1;
delete f2;
return 0;
}
>>
>>53668740
C wasn't around in 1911
>>
>>53668754
no generics, fuck off
rust is better
>>
>>53668773
Java is clearly superior
>>
>>53668784
java isn't in its infancy
>>
I don't think that Go and Rust are interchangeable languages for the projects that use Go and that use Rust.
>>
>>53668754
No, because most of the people here are probably in a CS class.
>>
>>53668745
Initialize Attack so that it contains a reference to the parent;
Attack(Fighter fighter)

then use a getter method to get the strength attribute;
int Fighter.getStrength()
>>
>>53668799
i disagree
>>
>>53668773

> muh memory management
>>
>>53668795
Java is an infant
>>
>>53668732
thanks anon, rolling.

>>53668761
ehh... nah. Thanks though. (I know how to do this stuff in C, it would just be tedious)
>>
Why does C++ support both references and pointers?

Why not just pick one.
>>
>>53668834
>why does this language support useful features, it's too many for my brain to hold
are you the same faggots who say c# is too bloated?
>>
>>53668834
Legacy and both are useful for different things.
>>
>>53668834
They have different behaviors... That's like asking why they have different types of smart pointers
>>
>>53668818
>>53668745
Don't listen to that guy. The Fighter and Attack classes should contain no reference to each other. You need a third class to handle the messaging between the Fighter and his Attack.
>>
>>53668850
>>53668855
>>53668857
C++ is a meme language.
>>
>>53668821
Rust should be used when you need speed and Go should be used when you're lazy and you don't need speed, and would rather shit out a lot of simple code.

>>53668834
Pointers should be used sparingly, because references usually do the job. However they are definitely times when you need to use pointers and a reference would not work (e.g. pointing to heap data).
>>
>>53668891
t. retard
>>
>>53668894
rust values safety over speed
if you want speed there's always C
>>
>>53668914
C favors readability over speed.
If you want speed there's always assembly
>>
>>53668834
One's nullable and one's immutable
>>
>>53668914
>rust values safety
No
>>
File: goats.jpg (40 KB, 200x200) Image search: [Google]
goats.jpg
40 KB, 200x200
>>53668938
why are you memeing your way into a discussion you know nothing about?
>>
>>53668952
We talked about this some threads ago.
Don't talk about things you have no idea about.
>>
>>53668914
Rust is super comfy and pretty much just as fast and you will have less memory bugs, with a downside of a tiny bit less speed. Why would I want to use C when I could use Rust and get generics and lambdas and enums and memory management for free?

>>53668938
Rust was literally created to be a safe systems programming language
>>
I'm tired of being a babby using Java and Python.
I want to learn a manly language that won't hold my hand.

Should I learn C or C++
>>
>>53668982
>safe
>systems programming
If you try to combine these two, you are a faggot
>>
>>53668973
i'm not here for every /dpt/, i'm sorry.
what did i miss?
>>53668982
>Why would I want to use C when I could use Rust and get generics and lambdas and enums and memory management for free?
rust isn't a good idea to use everywhere C is usd just yet
maybe once every system comes with a rust compiler along with a c compiler
>>
>>53668987
C.
>>
Hey guys

Theres some apparent huge issue with my code in that nothing shows up in the console when I run it and I can't figure out why

There are no errors, and if I add some it gives me red text like usual for errors in the console, but otherwise nothing is there
Thread replies: 255
Thread images: 23

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

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