[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 - switch-on-symbols edition
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: 36
File: Asa_Archives,_Kathmandu(1).jpg (314 KB, 800x534) Image search: [Google]
Asa_Archives,_Kathmandu(1).jpg
314 KB, 800x534
What are you working on, /g/?

(match op ['handsome #t] ['marvelous #t] ['the-best #t])
>>
>>53788879
>didn't link last thread

I bet you're ugly, too.
>>
File: racket.png (18 KB, 396x120) Image search: [Google]
racket.png
18 KB, 396x120
!!!!!!!!!!!!!!
prev thread >>53779743

It's OK, OP, we're not all perfect like Racket
>>
Someone give me something to work on.
>>
>>53789013
Check out a new PL. Not going to suggest any tho because otherwise there will be a flamewar.
>>
>>53789013
http://docs.botframework.com/
>>
>>53789050
That's the problem though. I am trying out a new language I just have no interesting project ideas.
>>
>>53789079
ウィアブー去ってください。
>>
>>53789061
Write an IRC bot.
>>
>>53789079
>>53789111
I feel excluded and that's literally rape.

Check your chink-language privilege.
>>
>>53789061
Make a GUI minesweeper, it will be fun!
>>
File: 1341139192879.jpg (116 KB, 600x600) Image search: [Google]
1341139192879.jpg
116 KB, 600x600
>>53788879
Does anybody have a good read up on Red Black Binary Trees with some pseudocode/agorithms?

In general I understand how they are supposed to work, but when it comes to the rotation stuff, I start sperging hard because I don't really get how far to go up and how to handle different cases. Seems like there isn't a clear cut way to do it from what I've found. Every time I check what I work out on paper, it's always off.
>>
>>53789061
Make a terminal multiplexer, there's a lot of interesting logic to implement.
>>
Wellp, Xamarin is now open sourced. MIT licenced too.

It's a good day to be part of the .NET master race.

Non-.NET langugaes confirmed for garbage.
>>
File: Untitled.png (5 KB, 245x210) Image search: [Google]
Untitled.png
5 KB, 245x210
Noob question.

Why am I only getting the right answer by doing subtraction first?
>>
>>53789435
Your shunt is fucked.
>>
>>53789502
How so?
>>
>>53789435
What are you even trying to do anon? Looks like an RPN buts what's with all the random numbers in the first 2 lines?
>>
>>53789569
The first line is the RPN.
The second line indicates what in the RPN is a value and what is an operator.
The operators are listed as ints rather than chars because I am too lazy to cast them.

They are listed below during the operation in the order they are in the RPN though.
>>
>>53789326
>As of today, we are including Xamarin in Visual Studio at no extra cost.

>Xamarin will be in every edition of Visual Studio, including the widely-available Visual Studio Community Edition, which is free for individual developers, open source projects, academic research, education, and small professional teams. Develop and publish native apps for iOS and Android with C# or F# from directly within Visual Studio with no limits on app size.

Hnnnngh, my dick.

This is pretty exciting, actually.
>>
>>53789601
Stop coding please.
>>
>>53789615
Okay Simon Cowell.
>>
>>53789609
Meh, I'd rather they started properly pushing F#...
>>
File: 1457030897749.jpg (23 KB, 400x540) Image search: [Google]
1457030897749.jpg
23 KB, 400x540
>>53789615
>Want to practice my code
>DPT tells me to make a shunting yard algorithm and calls me a retard
>Get stuck at the very end when it almost works
>Wow just stop coding retard
>>
>>53789435
See >>53789662
>>
>>53789673
>calls me a retard
/dpt/ is always right
>>
>>53789701
FUCK OFF, DAD

I DON'T EVEN WANT YOUR APPROVAL
>>
>>53789673
Yes, you're almost there, but somehow your code doesn't treat operators with the same priority the same, that's all. Dud you notice that's how you mentally decompose polynoms? Monoms separated by either + or - ?
>>
>>53789735
Oh, I gave + a higher priority than -

Time to sleep I think.
>>
>>53789637
I'd like them to push F# more, but this is pretty great. Xamarin has great support for F#. Miguel has a boner for it. He has seen the light.
>>
>>53789326
that's pretty neat
>>
my asian professor is so based. explaining journaling file systems:
"It is like you go to college for 1 year, go to military fight in iraq. when you come back your post traumatic stress disorder cannot remember your classes. you must journal it down so you know "where to start back off, otherwise crash.
>>
>>53789673
Don't get down dude, I tried to do a shunt early in my programming life and it worked but looked like shit.

Came back to it a month later and made an entirely new one that was very nice.
>>
a fucking array is literally the most useful and versatile datter strukter
>>
test
>>
>>53790116
That's not an enumerable object in C#.
>>
>>53789761
That's all and well, but it matters little when programmers (or managers :^)) in your typical C# businesses have no idea about F#'s existence, let alone its superiority. Shame Microsoft does not spread the gospel of F#.
>>
Quickly! Tell me if this is gonna work or not without using your compiler:

in foo.c:
int a[3] = {10, 20, 30};


in main.c:
#include <stdio.h>

extern int *a;

int main(void)
{
printf("%d\n", a[1]); /* prints 20 or crash? */
return 0;
}
>>
>>53790163
tip harder
>>
>>53790163
Now that Xamarin is part of MS, there might be a bigger internal push for it.
>>
>>53790177
No.
You didn't include foo.c.
>>
>>53790177
crash
>>
>>53790177
maybe
>>
>>53790191
>internal push
Perhaps, but I wonder if that's going to have any impact on awareness and adoption. Fuck, I hope it does though; I am tired of accidentally doing this shit in C# at work:
someArray.[0]
.
>>
>>53790261
I'm with you man. They should be pushing it like Apple is pushing Swift. I suspect internal politics are at play.
>>
>>53790261
>>53790286
In the meantime we can continue shitposting about it on /dpt/ to help spread the word of God (Don Syme).
>>
File: fsharp256.png (3 KB, 256x256) Image search: [Google]
fsharp256.png
3 KB, 256x256
>>53790301
And hope for the second coming of his Son (Tomáš P.)
>>
hey i need help on my homework, can you write me a function bool isOdd(int n)?
>>
Why is metamorphosis not a thing in OOP /g/?

Say you have a simple minesweeper game, with a nice inheritance™ hierarchy with Unrevealed, Mine and NoMine all inheriting from Tile. Now, you notice that, when a tile is revealed, it has to *become* a Mine or NoMine object in-place. Maybe you can just change the reference in the array and be done with it... or maybe not? It's fragile.

Say you have a KeyMap type which you want to microoptimise for access rather than mutation. You decide that, if there are 2 or 3 mappings, you're better off using a hash table, but if the full 256 of them are here, it had better be a packed O(1) access array. Since this means that mutating the object can suddenly make it change its entire structure and thus class, how do you do that?

What we could do is declare the objects immutable and return altered copies. We could also write a wrapper object with a reference to the object that we can freely mutate without this showing through, but design patterns are workarounds for language defects, so fuck that. Java® Object® Model® does not have an easy answer for this easy question...

Any documentation about the problem I'm not aware of?
>>
>>53790318
I fucking hate that logo tho.. I actually helped fund it. I think they raised like $3000 or more to get it made. Then they guy organising the shit gave it to some 1st year graphic design student who has done nothing but utter shit. She did 5 other designs to pick from which all looked 1000 times worse. It must have been someone he knew.

You can hire a VERY talented professional graphic designer fro $3,000. So fucking mad about it still. Sadly programmers are not a bunch who generally have any visual design taste at all :/.
>>
>>53790346
bool isOdd(int n) {
return True; // were all odd in some way... being normal should be looked down upon
}
>>
>>53790404
*solemnly raises spork in agreement and nods respectfully to you*
>>
>>53790347
So how would you handle reallocation of memory if the type suddenly changes?
>>
>>53790347
>Since this means that mutating the object can suddenly make it change its entire structure and thus class, how do you do that?
In Java, you can't.
>>
ECMAScript 6 is useful for writing robust, high quality and reliable software. You can write the same stuff in any other language. But ECMAScript 6 is designed based on solid mathematical principles. It is statically typed which allows the compiler to detect certain classes of bugs which are impossible for compilers for C++, Java, Python etc. to detect. ECMAScript 6 compiler can also perform optimizations which cannot be performed for other mainstream languages. ECMAScript 6 focuses on modularity and composability by virtue of pure functions with no state changes. Code with state changes is neatly separated from code without state changes, allowing you to zero in easily, onto the bugs. ECMAScript 6 emphasizes a different style of programming with an extremely minimalistic and simple syntax( devoid of colons, braces, brackets and other ugly looking special characters) making your code look like a Mozart or Beethoven masterpiece.
Its a truism in the ECMAScript 6 community that if your code compiles, then it will do what you want it to do.
>>
>>53790346
if([the remainder after you divide n by 2] == 0)
is even
else
is odd
>>
MEMES != DREAMS

https://www.youtube.com/watch?v=kgYSYR0-TZM
>>
>>53789673
Hey I remember you. You should have really figured out how to make that algo work by now m8. Don't blame anyone else.
>>
>>53790346
isOdd(int n)
{
return !isEven(n);
}
>>
>>53790725
>ECMAScript 6
>statically typed
What are you smoking?
>>
>>53790346
require('is-odd-integer')
>>
>>53790798
It's a meme you dip

Haskell is useful for writing robust, high quality and reliable software. You can write the same stuff in any other language. But Haskell is designed based on solid mathematical principles. It is statically typed which allows the compiler to detect certain classes of bugs which are impossible for compilers for C++, Java, Python etc. to detect. Haskell compiler can also perform optimizations which cannot be performed for other mainstream languages. Haskell focuses on modularity and composability by virtue of pure functions with no state changes. Code with state changes is neatly separated from code without state changes, allowing you to zero in easily, onto the bugs. Haskell emphasizes a different style of programming with an extremely minimalistic and simple syntax( devoid of colons, braces, brackets and other ugly looking special characters) making your code look like a Mozart or Beethoven masterpiece.
Its a truism in the Haskell community that if your code compiles, then it will do what you want it to do.
>>
>>53790786
isEven(int n)
{
return !isOdd(n);
}
>>
>>53790855
>It's a meme you dip
Good one

>Haskell
Purist garbage
>>
>>53790960
You're not getting it

https://www.reddit.com/r/ProgrammerHumor/comments/4clfzn/deconstructing_the_malicious_autistic_lies_of/d1jag37
>>
File: pepegun.png (307 KB, 550x535) Image search: [Google]
pepegun.png
307 KB, 550x535
>tfw have to port a thousand something command line c++ program to a GUI program in some hours
>>
>>53791129
What is that website?

Will it give my CPU viruses?
>>
>>53790346
return n&1
>>
>>53791142
So basically just write a GUI. A few hours isn't that hard using QT.
>>
>>53791211
HURR DURR ONE'S COMPLEMENT DURR
>>
>>53791229
just do
 if(!i%2 == 0) ... ;


It's a homework assignment not a cryptographic algorithm
>>
>>53791211
how does this work?
>>
>>53791260
make it != whatever you know what I mean
>>
>>53791285
It works because binary

An odd number always has the LSB a 1. This returns true when AND with 1 which in binary is 0b1.
>>
>>53791285
& is the logic and
all odd numbers end with 1 in binary, so it checks if the last digit is equal to 1
>>
I want to write a Castlevania AoS clone, but I don't want to use a layer library between the graphics and the code.
I want to learn it the hard way, and using C/C++.
I'd like to code it in a way that's very similar to programming for SNES/GBA.
Which graphics library and language should I pick?
>>
>>53791357
Have you ever programmed before?
>>
>Tfw I feel like shit that I have micro transactions and ads in my mobile applications but I am too much money to disable them

What it do?
>>
>>53791357
SFML
>>
>>53791381
Learn English.
>>
>>53791381
You should probably go back to india
>>
>>53791442
No I like pooping out on the street and in your backyard
>>
Have you switched to quadnary coding already /g/?
https://www.youtube.com/watch?v=RVhHNVguMWo&spfreload=5
>>
>>53791461
No.
>>
>>53791376
Yes. I know that my question sounds silly, but I'm very fascinated by old style game programming. I wish I could read something about it, but never found anything.
>>53791413
I'd prefer SDL, but the goal is to write my own library after various prototypes.
>>
>>53790177
It will work.
>>
>>53791494
Okay apparently not.
Why?
>>
>>53791493
Old style game programming was done in assembly for hardware specific processors m8. That's why we need emulators, mostly done in SDL/SFML and C/C++. So you have those options.
>>
>>53791537
extern pointers are stupid
>>
File: racistcomputers.jpg (22 KB, 450x200) Image search: [Google]
racistcomputers.jpg
22 KB, 450x200
>>53791461
Niggers, every time.
https://www.kickstarter.com/projects/1784334872/4-dimensional-operating-system/description
>>
>>53791493
>Yes. I know that my question sounds silly, but I'm very fascinated by old style game programming.
Non-insulting question: Are you anywhere in the autism spectrum?

If not, it's unlikely you'll actually see your project to completion using older, inconvenient programming tools and systems.
>>
Is it okay to assign values to variable outside a function/method? Like:


class SomeClass {
var Foo = value;

retVal SomeFunction() {
..use Foo for something..
}
}

>>
>>53791537
Pointers are not arrays.
>>
>>53791591
>Is it okay
You can do whatever you want, anon.

Is it best practice in every situation?
No.
Is it fine in some situations?
Yes.

Ideally, you should generally pass data around as return types and parameters to functions, but having Foo sit outside of all the noise ready to be read or written to is sometimes fine.
>>
>>53791569
>Those "Risks and challenges"

He's like a national treasure
>>
>>53788879
>about to enter a $20/hr paid internship

thanks for recommending python to me, /g/
>>
>>53791538
I'm not sure, I downloaded GBA SDK and there was a C compiler.
>>53791570
I don't know, probably yes.
You're right but learning from old style game programming could teach me a lot of things about optimization, because they had to work with restricted memories.
>>
>>53789701
>degree in physics
>engineer at a fortune 500 tech company
>/dpt/ calls me retarded nearly daily
meh
>>
>>53791569
>https://www.kickstarter.com/projects/1784334872/4-dimensional-operating-system/description

>Many times I have thought that to myself that computers would work better if you could just "add a two" in binary code. Because of advances in technology, it is now possible to do even more than that.

what advances in technology allows us to change how mathematics work?
>>
>>53791634
At least when I'm depressed I can think: "At least I'm not him"
>>
File: 1459431620766.png (865 KB, 1093x603) Image search: [Google]
1459431620766.png
865 KB, 1093x603
>>53791644
You're welcome girl. Now allow me to go back to being a feminist superhero.
>>
>>53791681
>>degree in physics
>>engineer at a fortune 500 tech company
And? For you it's a proof of non retarded? You're retarded.
>>
>>53791689
But I'm a guy.
>>
>>53791682
maybe he wants to replace every transistor with a small computer..
>>
Can anyone explain fucking pointers to me?

I need to keep track of multiple points in the map and their links and it's pretty obvious I need to make a linked list.
And while I understand the concept I can't fucking get my head around how to define and use them.
>>
>>53791681
status is irrelevant
that's the whole point of this place, remember?
>>
>>53791661
A C compiler written in, guess what, assembly. If you want to go ahead and write a compiler for C, by all means, knock yourself out.
>>
>>53791709
trap at best
>>
>>53791681
>succeeding in life
And you still visit /dpt/?

I see a lying man.
>>
>>53791712
a pointer if just a datatype that represents a address in memory. You can use a pointer to access the data at a specific memory address. What's the problem?
>>
>>53791682
https://answers.yahoo.com/question/index?qid=20130331224635AANXaMX

according to yahoo answers, no.

>There have been revisions of binary coding. They were enhancements to it's capabilities, but no numbers have been added.
>>
Learning ACNEScript via that Eloquent JS book.
>>
>>53791720
How does the fact that GBA C compiler is written in assembly means that GBA games are written in assembly?
>>
>>53791712
Do you know what a reference is? If yes, you know what a pointer is, it's the same thing.
>>
>>53791720
>A C compiler written in, guess what, assembly
LOL, why does it make a difference what the compiler was written in?
>>
First time using SVGs (yeah, I'm a fucking baby, I know). When src the SVG inside an <a> tag, I get these tiny blue lines next to the SVG which serve as the link, instead of the SVG itself being clickable. Is there any way to fix this?

<div id="social-media">
<a href="http://www.google.com/">
<object data="<?php bloginfo('template_url'); ?>/library/images/ig.svg" type="image/svg+xml" width="36px" height="auto"></object>
</a>
<a href="http://www.google.com/">
<object data="<?php bloginfo('template_url'); ?>/library/images/tw.svg" type="image/svg+xml" width="36px" height="auto"></object>
</a>
<a href="http://www.google.com/">
<object data="<?php bloginfo('template_url'); ?>/library/images/fb.svg" type="image/svg+xml" width="36px" height="auto"></object>
</a>
</div>


Oh, and, yeah-- it's fucking wordpress. Sorry about that.
>>
>>53791785
>>>/wdg/
Seriously, they're expert in shit like that.
>>
>>53791806

Fuck, I forgot we had a thread for that. Sorry!
>>
>>53791761
Most games were written in assembly, you brought up an example of one that uses a heavily engineered compiler in place of assembly. You didn't say anything about GBA before hand.
>>
>>53791785
A elements can not store block elements like object.
>>
File: 1458674089890.jpg (24 KB, 600x338) Image search: [Google]
1458674089890.jpg
24 KB, 600x338
Working on my file server with torrent support.
I just got file removal working.
>>
>>53791712
You declare pointer variables with
T *ptr;
where T is the type you want to point to. T can also be a pointer, then it's just
U **ptr;
where T is pointer-to-U. As for getting values to store into pointer variables, that is, pointers, you can use the
&place
construct, where place is in most cases a variable, but really any "place" (fuzzy concept, but it's good enough) in memory into which you could store a value with = will do. You also have a special value, NULL (or nullptr in modern C++), which can be converted implicitely to any pointer type, evaluates to false in boolean contexts (that's not C terminology but fuck off) and should never be dereferenced. Dereferencing is done by putting * in front of a pointer, just like the pointer variable declaraction syntax suggest. It lets you access the pointed-to thing, get its value, or assign to it with =.

There's also pointer arithmetics, arrays and pointer to functions, but this should be enough to write a linked-list. Or maybe you need heap allocation for your linked list?
>>
File: Untitled.png (4 KB, 312x91) Image search: [Google]
Untitled.png
4 KB, 312x91
>>53791745
What I'm trying to wrap my head around is when I should use them and why.

Pic related, I never defined, nor overridden any copy constructor to load the address of a pointer and push it into my object. But it says to make it so and doesn't allow me any workaround.
>>
>>53791827
Yes, I said
>I downloaded GBA SDK and there was a C compiler.
But never mind. Should I go for OpenGL?
SDL seems fine but does it worsen the performance? Am I restricted by the library?
>>
>>53791934
n should be a pointer variable, now that I've posted >>53791931 it should help you ;^)
>>
>>53791936
SDL is very optimized. If you're just making a GBA emulator, then it won't do shit to effect performance. I still recommend you use SFML because graphics are displayed using opcodes. You should only be worrying about performance if you're developing some PS2 emulator or some shit.
>>
File: uRW7wgj.jpg (546 KB, 2448x3264) Image search: [Google]
uRW7wgj.jpg
546 KB, 2448x3264
>>53791827
>>53791720
the official sdk had a c compiler, the systems calls were described as C procedures, and the demos/examples were written in c.
>>
>>53791963
Fucking space magic I tell you, it just works.

As for the heap allocation, I won't need it since nothing will ever leave the scope of the class and I always forget destructors.
>>
>>53792018
I don't want to write a GBA emulator, but a GBA style game. OpenGL seems focused on 3D.
I'll check SFML!
>>
>>53792054
>nothing will ever leave the scope of the class
What do you mean? What scope exactly?
>>
File: 45I4ksR.jpg (19 KB, 579x329) Image search: [Google]
45I4ksR.jpg
19 KB, 579x329
>>53792057
>OpenGL seems focused on 3D
>mfw
>>
>>53792057
There's also stuff like monogame if you like C#.
>>
>>53792093
you only realised this now? Wow, that must be quite the shock =(
>>
>>53792057
OpenGL can be perfectly used to draw 2D graphics.
>>
>>53791461
>>53791569
lmao jesus when can we go back to classifying them as subhuman
>>
In dynamically typed languages, e. g. Python, Ruby, JavaScript, but not Scheme, what is the rationale for distinguishing between the cannonical false value, the one the negation operator always return, and the None/null/nil value, which is used when there's nothing meaningful?
>>
>>53790346
isOdd :: Integral a => a -> Bool
isOdd 0 = False
isOdd n = isEven $ n - 1

isEven :: Integral a => a -> Bool
isEven 0 = True
isEven n = isOdd $ n - 1
>>
>>53792172
Don't ask questions that you don't want to know the answer to.
>>
>>53791461
>i can't memorize a single programming language
>i can't write more than 1000 lines of cohesive code

>i'm gonna write a quadnary compiler gibe moni plox
>>
>>53792197
WTF?
>>
>>53792081
Well pretty much everything my program will do will be done in a single class.

Yes it does reference other classes and use their methods, but the linked list itself is stored in the main class.

Now since c++ doesn't have a garbage collector you'd need destructors for everything that gets made on the heap with 'new', something that I always forget.
This is where I notice that I call new right there and feel like a retard.
>>
>>53792190
Beautiful.
>>
>>53792172
What do you mean? Those values are distinct and they have distinct types (NoneType and bool in python, undefined and Bool in JS etc.).
>>
>>53792228
Why is this so? Scheme does with using #f for denoting the absence of a value as well as the opposite of true, so why is this so?
>>
>>53788879

http://codepen.io/anon/pen/aNLbJZ?editors=0010

w-why does this slow down so much? It's only removing DOM elements.
>>
>>53792172
this ?

def foo(o):
if o is None:
print("o is None")
elif o is False:
print("o is False")

foo(False)
foo(None)
>>
>>53792255
>Scheme does with using #f for denoting the absence of a value
no true. see (values) for an example of a procedure that doesn't return anything.
>>
File: vaccine.png (104 KB, 1289x813) Image search: [Google]
vaccine.png
104 KB, 1289x813
I fixed the AUR package
>>
>>53792286
Yes. why is it that
None is not False
?

>>53792321
You can't pass
(values)
in an optional argument, a different number of values and a "nothing particular" value aren't on the same level.
>>
>>53792352
because `None != False`
>>
>>53792352
>Yes. why is it that None is not False?
It is called strong typing. They are two completely different data types.
>>
>>53792255
Uh, I don't know Scheme and why it does wat it does, but false boolean value is a certain value, and None/null are special values indicating no useful value.
They have distinct semantic.
Consider a predicate function foo(x) -> bool|None. The function can return a a boolean value true or false, but it can also return a special value None, indicating the function can't compute an answer. This is called ternary logic.
None (and undefined in JS) is useful to denote a value is not set yet. First you set a variable to None, then at some different point you might set it to True/False, but to test if it is set you test if it's None (is None in python). If you've initialized it to False, you couldn't detect if it was already set or not. Maybe such considerations aren't important in Scheme, as it's more of a declarative than imperative language.
>>
>>53792352
Because None is a reference to a non-existent object, whereas False is an object of type bool. They are distinct concepts, even if None is treated as False if it is used where a Boolean expression is expected.
>>
File: 1458427209947.gif (526 KB, 364x489) Image search: [Google]
1458427209947.gif
526 KB, 364x489
I need some help.
Okay, so I'm trying to do a program that goes through multiple cases.

It goes through an arrays of int of two dimensions [a][b] and compares elements [a+1][b] and [a][b+1] and then it decides which direction/element it should move to.
The case when one is superior to the other is fine, I would go i-- or j--
However, I still need to do the case when both are equal, I have to branch to another result and display it as well, and it just branches randomly every case and I don't know how to code it.
I'm under Java, using arrays.
Please help
>>
>>53790541
that's the point
>>
>>53792437
What's the point?
>>
>>53792391
>Because None is a reference to a non-existent object
No, None is an existing singleton object created by the interpreter. It has all the basic stuff like a __class__or __hash__.
>>
>>53792446
he's talking about a concept that's not available in most languages and making a point for it
>>
>>53792453
Although, it's special because the interpreter blocks assigning to it or deleting it.
>>
>>53792377
So you'd pollute the whole language just for ternary logic? I thought about that before, but it didn't seem plausible to me. Even if you're able to implement the ternary logic like that, you have to make your own type if you want anything else, so why is that such a pain to make your own type for ternaries?
>>
>>53792352
could be useful to have a distinct value for representing nothing. For example

# Does the customer want coffee in his milk ?
if customer.wantMilk is None:
# Customer hasn't answered yet, ask him again
if customer.wantMilk: # True
# Customer does want milk
elif not customer.wantMilk: # False
# Customer doesn't want milk.
>>
I have this assembly code (mips)
reverse:
lw $t2, ($t0)
lw $t3, ($t1)
sw $t2, ($t1)
sw $t3, ($t0)

addi $t0, $t0, 4
addi $t1, $t1, -4
blt $t0, $t1, reverse
bne $t0, $t1, reverse
jr $ra


it's supposed to take a string and reverse it in place, the bytes swap correctly but when I try to print the string nothing happens (I stored the original address in a different register and then loaded it back in to $a0)

why doesn't this work?
>>
>>53792471
Pollute? What?
>so why is that such a pain to make your own type for ternaries?
You can make your own type if you want.

It's not only about bool. Every name can be assigned None. That is, all types are nullable (see: https://en.wikipedia.org/wiki/Nullable_type). It's the equivalent of ? types in C# or maybe in Haskell.
>>
>>53792466
you can do it in C and C++ and shite. You can do it in C# if you are man enough to fuck with heap object metadata with pointers
>>
>>53792494
>muh tri state boolean
>>
>>53792521
>? types in C#
>>
File: Mastery.png (40 KB, 501x270) Image search: [Google]
Mastery.png
40 KB, 501x270
>oh look, a linux se job near me that want's C, not java or web*
>requirements

Emphasis theirs.
>>
>>53792558
Not at all. A Boolean is a value while none does means there no value. In databases, a null is usually used for "unknow".
>>
>>53792596
>Mastery of C

lel
>>
>>53792596
>Ability to navigate complex makefiles twice
>Clearcase twice
I'd move a large step away from that job, that shit implies terrible things.
>>
>>53792453
Ah, didn't know that.
>>
>>53792657
>"please someone fix our makefile monstrosities"
>>
>>53792636
I disagree. Primitives should always have a default value. Databases are an exception.
>>
>>53792688
That's probably pretty accurate, it was listed as a 6 month contract position.
>>
>>53791710
And every one of them is gonna be four-dimensional, and every one of them is gonna be quadnary instead of binary.

Fucking goldmine
>>
>>53792591
What are you implying?
>>
// Convert each pair of digits into an octet, in reverse order.
// 'i' is the input (scale 2) and 'j' the output index.
// 'i' is post-decremented in the loop condition to avoid
// unsigned underflow.
for (size_t i = len / 2, j = 0; i-- > 0; ++j)
{
uint8_t x;

if (!decode_pair(&x, &in[i * 2]))
{
return false;
}

memcpy(&out[j], &x, 1);
}

Rate my comments.
I'm trying to find a balance between implicit idiomatic C and explicit logical/formal semantic commentary.
>>
>>53792823
http://www.lysator.liu.se/c/pikestyle.html
>>
>>53791461
I hope big binary assassinates this insurgent
>>
http://blogs.wsj.com/digits/2016/03/17/study-immigrants-founded-51-of-u-s-billion-dollar-startups/

>Study: Immigrants Founded 51% of U.S. Billion-Dollar Startups

>According to the study, founders of billion-dollar startups most often hail from India (14), followed by Canada and the U.K., with eight each, then Israel (7) and Germany (4). Two originated from France and the Collison brothers, the co-founders of payments startup Stripe, make up the pair from Ireland.

And all you can do is crack some "witty" Pajeet jokes
>>
>>53792839
Thank you, I'll read this. Rob Pike is the #1 idiot who's opinions I by far too large agree with.
(Syntax highlighting is for babies)
>>
>>53792905
So, what you're saying, is that Canadians have the best chance of being successful? (population sizes)
>>
>>53792905
I do. I'm Irish. Statistically we do a lot better than the prajeets.
>>
>>53792905
So the top percentage of the top percentage of pajeets move to the USA and are successful? Who'd have thunk it?
>>
File: pajeet on facebook poo 2 loo.png (783 KB, 1440x2560) Image search: [Google]
pajeet on facebook poo 2 loo.png
783 KB, 1440x2560
>>53792905
>>
>>53792823
// The most and the least significant quartet.
uint8_t msq, lsq;

// Decode and error check both digits.
if ((msq = decode_digit(in[0])) == UINT8_MAX ||
(lsq = decode_digit(in[1])) == UINT8_MAX)
{
return false;
}

// Write the resulting octet to output.
*out = (uint8_t)(msq << 4) | lsq;

More.
I guess the big idea is figuring out the most effective prose without insulting your reader's intelligence and limited time or interest.
Comments are easy are ignore, long variable names less so.
>>
File: 1458871748533.gif (868 KB, 540x350) Image search: [Google]
1458871748533.gif
868 KB, 540x350
>>53792416
No one knows or am I explaining this pretty bad?
>>
>>53793216
The latter. Show us your code.
>>
>>53793216
Grab a piece of paper and figure it out.
Every programmer should learn to write code with just graphite and wood pulp.
>>
It doesn't branch randomly unless you use something random. Your function works in a deterministic fashion...
>>
File: pysoccer.webm (1 MB, 1920x1080) Image search: [Google]
pysoccer.webm
1 MB, 1920x1080
Still working on my soccer game.
>>
>>53793402
What is that? Pygame or Pyglet? Kivy?
>>
>>53793402
What are you doing with the lines?
>>
>>53793232
Okay here it is:
http://pastebin.com/P8XXQJTS

X and Y are user provided Strings, I'm using X=GAC and X=AGCAT to test.

I generate an int array with this criteria (imagine X and Y as a two dimensional string array):
- If X = Y at a certain index, the numeric array at the equivalent (x,y) indexes will be equal to 1 plus the value diagonally to the upper left.
- If they're not equal, we check what is bigger: the element at the top, or the element to the left. The cell in the numeric table in question takes the bigger number from these two.

And now, the tricky part: all the multiple sub-sequences, I have to backtrack, and when I do, there are multiple cases. For example, I get to a place where they're equal, and I'm not exactly sure what to do.
I tried to make an array now to keep track of the indexes where they're equal, but then I have to do it again for the new results, I'm not sure how to loop it.
Basically I'm stuck.
>>
>>53793440
>Pygame
Yes.

>>53793462
It's a turn based game. Each user (they are two) register actions for each player. And when everything is set the actions are resolved. Now I just have movements. Next step is adding the ball and passes.
>>
>>53793513
Sounds like a dynamic programming + recursion problem. Is this for univ? Why are you approaching the problem in a sequential fashion?
>>
>>53792702
Not the exception. Ever heard of the null pattern or float NaN ? Do you even code ?
>>
>>53793402
Make a subbuteo game. I'd play that shit.
>>
>>53793562
>Dynamic programming
I'm not sure what that is, I only took a couple of programming classes so far.
Well, it's kind of for it, it was one of the problems of the past year's programming competition.
>>
File: ypLqggl.png (603 KB, 612x612) Image search: [Google]
ypLqggl.png
603 KB, 612x612
Let's say I've got 4 symbols, A, B, C, and D

each value is placed into a 2d array, where the first dimension stores the symbol, and the second stores the likelihood that the symbol will be selected by some function, f

E.g:

A, 0.2
B, 0.05
C, 0.5
D, 0.25

How can I write a function which will get a random number, and based on that number, select one of the symbols probabilistically
>>
>>53793513
>http://pastebin.com/P8XXQJTS
Try commenting your code.
(Not being a dick but that's a fucking mess which meaning you'll forget in about the time it takes you to go to the shop)
>>
>>53793603
It has been forever since I had to use it: but this explains it, along with your problem: https://www.youtube.com/watch?v=aSwu8Z9nzOg.
>>
>>53793603

>dynamic programming
Store results of subproblems in memory so you don't need to recompute them.

Dynamic programming is the difference between an O(n) and O(2^n) Fibonacci.
>>
I have a progress prompt in my for loop and I'd like it to print to stdout only once every 20,000 iterations of the loop, how would I go about doin that?

This is C, btw.
>>
>>53793677
index % 20000 == 0
>>
>>53791357
You can start with this http://pastebin.com/AcmcNzMX
>>
File: 1458092953521.jpg (46 KB, 401x413) Image search: [Google]
1458092953521.jpg
46 KB, 401x413
>>53793647
Sorry my code is like Jeb Bush.
I'll try to comment more, I do forget about code I wrote in more than 2 days.
>>53793649
>>53793673
Thanks guys, I'll check it out!
>>
>>53793645
Google around for weighted random random choice.
>>
>>53793677
for (int i = 0; i < 80000; i++){
//Whatever you're calculating
if (i%20000 == 0)
prtinf ("progress...\n);
}


% is the modulo operator. It gets the remainder (sort of) of a / b.

So 7 % 4 is 3, because 7/4 is 1 remainder 3.

8%4 is 0 because 8/4 is 2 remainder 0.

i%20000 will only equal 0 at multiples of 20000

Or, if you're using array indices, you might say 19999 (which would be the 20,000th index in an array that begins at 0)
>>
>>53793677
Write a metaprogram to manually unroll the loop 20 000 times and insert a stdout at the bottom.
Don't enter the unrolled loop if you have less than 20k i remaining.
>>
>>53793736
I think the biggest lesson I learned from programming on/off for more than a decade so far is how limited my feeble thinking box is.
I mean that's why we use computers for our perverse biddings in the first place.
>>
And SJWs tell us that programmers don't need "advanced math" like modulus operators.
>>
>>53793943
Why do you have a tripcode? Are you better than the other anons?
>>
>>53793759
>prtinf
That's my true name.
>>
>>53793984

>Why do you have a tripcode?
Because I can.

>Are you better than the other anons?
Some anons, yes. Some anons, no. I have never made the claim that I am the best programmer here.
>>
>>53793943
>don't need "advanced math" like modulus operators.
I thought that as a parody of the "invert a binary tree on a whiteboard" rant. Was that actually real?
>>
>>53794024
I was just teasing. What's the CUDA tripcode thing called again? Tripcode explorer?
>>
File: awoo2.png (1 MB, 1072x1273) Image search: [Google]
awoo2.png
1 MB, 1072x1273
Does anyone want to try my h2testw implementation?
>>
hello family
>>
>>53794081
suc dik nao
>>
>>53793402
Have you thought about using a hex grid or something by the way?
Perhaps something like civ but obviously the hexes would be much smaller, perhaps that could clean up how the game actually works, for it seems like it could get quite messy in current state.
>>
File: what_its_like_to_use_C.png (468 KB, 936x550) Image search: [Google]
what_its_like_to_use_C.png
468 KB, 936x550
>>53794098
Tell me where it all went wrong
>>
>>53794127

I wish I knew.
>>
>>53794124
>Have you thought about using a hex grid or something by the way?
Yes. But I prefer a more "free" game.
>>
>>53794024
Side tangent, would you say the best programmers are the presenters at conventions like Black Hat or Defcon? Certainly hard to quantify, but I would say they are on the top.
>>
>>53794063
I'm not aware of any CUDA ones, though there's MTY (ATI's CAL assembly), and I believe a new OpenCL one written by a Japanese guy (he posted the code and was discussing it on /g/ sometime in the last year) that's better than MTY by about 50%.
>>
should i try teach the succubus that fucks my brains out every night how to program in C?
>>
if(sad()){
sad().stop();
be_happy(forever);
}else{ happy.continue();}
// :3
>>
>>53794140
>>53794098
>>53794127

Did you just interview somewhere or something?
>>
>>53794230
tell your tulpa to change hosts.
>>
My h2testw implementation is making my CPU run really hot, it even kicked my fans into max speed.

All it's doing is generating 1 byte and fwrite() it to the disk.
>>
>>53794328
*in a loop
>>
>>53794241

Google decided not to give me an offer because I didn't know how to invert a binary tree.
>>
I made a thing.
https://www.shadertoy.com/view/4sdSDN
>>
>>53790346
function isOdd(n){
if (n === 1) {
return true;
}
else if (n === 0) {
return false;
}
else if (n < 0) {
return isOdd(n + 2);
}
else {
return isOdd(n - 2);
}
}
>>
>>53794237
gay
>>
>>53794459
>java
>>
>>53794475
>===
>
>>
>>53794456
neat
>>
File: cute boy awoo.jpg (151 KB, 645x989) Image search: [Google]
cute boy awoo.jpg
151 KB, 645x989
Can someone try out my flash memory tester and tell me if it works?

https://paste.installgentoo.com/view/raw/02d88783
>>
File: uakari.jpg (148 KB, 500x500) Image search: [Google]
uakari.jpg
148 KB, 500x500
>>53794558
>
static const unsigned update_rate = 1024 * 1024 * 2; /* 200mb? */
>>
>>53794637
dem millibits
>>
>>53788879
Just programmed some machine learning algorithms to classify the MNIST dataset of handwritten digits.
My perceptron works, but my extreme learning machine keeps getting memory corruption errors.
>tfw they are both basically the same, but the ELM has preprocessing with random sigmoidal basis functions
>just adding this preprocessing fucks shit up

doing this in C++ using opencv for matrices.
I'm only using opencv because I already knew how to conveniently handle matrices with it.
>>
File: study3.webm (122 KB, 332x274) Image search: [Google]
study3.webm
122 KB, 332x274
Another lighting study. I went through the shader code line by line to understand it better. It's just the same Gouraud/Lambert shading/reflection stuff I've been going through. I'm feeling more confident now about the lighting code so now I'm going to work on some code that generates randomly shaped asteroids. Also made some improvements to the engine like adding a buffer class so buffers are much easier to work with. I've got to now make the game models have a shader program property so I don't have to manually switch programs when I want a different shader for different models. My next post should be a little more interesting.
>>
>>53788879
>What are you working on, /g/?
Same as usual lately. Working on some backend stuff in PHP. Nothing too exciting, really.
>>
What do you think of Terry Davis?
https://www.youtube.com/watch?v=ZrWZmBnnk0w

Is he the embodiment of /dpt/? Are we all gonna go crazy at some point in our lives?
>>
>>53794637
so did it work?
>>
>>53794833
>Is he the embodiment of /dpt/
no, because he can actually program.
>>
>>53794833
> at some point
>>
>>53794833
I like that GNU-bots circle jerk to using Linux for development when even TempleOS has 20 years more advanced command line workflow.
>>
>>53794833

> Davis is a former atheist who believes that he can "talk with God" and that God told him the operating system he built was God's official temple. According to Davis TempleOS is of 'Divine' intellect due to the inspired nature of the code. According to Davis, God said to create the operating system with 640x480, 16 colors display and a single audio voice. The operating system was coded in a programming language, developed by Davis in C/C++ called "HolyC". The OS runs a file system called "Red Sea".[4]

how long until he pulls an Ian Murdock
>>
>>53794888
Then again he also likes to yell about the jews and the black people on message boards
>>
>>53794960

Never. He is doing god's work. He will live eternally.
>>
>>53795039
Don't we all?
>>
>>53795062
No - no one who isn't an abrasive virgin or mentally ill.
>>
>>53795089
I'm a non-abrasive virgin and probably not mentally ill, no, I'm pretty sure I'm not mentally ill, I think, probably I'm not. And I still like to do all those things.
Thread replies: 255
Thread images: 36

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.