[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: 22
File: DPT.png (389 KB, 934x1000) Image search: [Google]
DPT.png
389 KB, 934x1000
Old thread: >>55506203

What are you working on /g/?
>>
C a shit
>>
>>55516010
Second for D
>>
File: 1467387907257.png (1 MB, 1000x1400) Image search: [Google]
1467387907257.png
1 MB, 1000x1400
You have been visited by the crossdressing C programmer of Shimoshina Academy!

Good performance, triple indirection, and tail call optimization will come to you, but only if you post "Keep overflowing the stack, Hime!" in this thread.
>>
Hi. Where the heck do I get the /g/s reccomended reading for programming picture?!? I want to learn!!!
>>
>>55516103
Don't pollute a fresh thread with your trash.
Also, triple indirection isn't a good thing.
>>
>>55516127
What if you need to pass an array of char arrays by reference?
>>
7nd for Lua
>>
>>55516144
You only need double indirection for that.
After double direction, you should seriously start questioning the design of your program.
>>
Angular 2 based web app for business productivity software startup.

I'm an idiot for trying to use a beta version of a JS framework to build an app on. It's been a fucking nightmare the past couple months. They keep changing up core parts of the framework, and I have to rewrite shit. It just demotivated me and I'm not even working on the frontend right now.
>>
Selenium tool that tests new builds of asp.net applications with different browsers that chains together complicated tests
>>
File: Disgaea_4u.jpg (299 KB, 935x529) Image search: [Google]
Disgaea_4u.jpg
299 KB, 935x529
>>55516010
Why does developers tends to avoid comments in functions and in their source code in general? I've seen that in semi-large projects that are good and usable.
I wonder how they manage to remember what their functions/classes does.
>>
>>55516125
Wiki
>>
WHAT THE FUCK DO I PROGRAM!! I HAVE NO IDEAS!!! I'M CREATIVELY DEAD!!!
>>
>>55516326
http://better-dpt-roll.github.io/
>>
>>55516326
Fucking google "programming project ideas," you soulless cunt.

You're a carpenter wandering around in a goddamn lumberyard, bitching for something to do. Disgusting.
>>
threadly reminder that you have to porgram every day or you'll lose your powers.
>>
Hey /g/ about a week ago I started to program for the first time in my life (I picked Haskell) and I was wondering when is the optimal moment to start learning about data structures/algorithms and all that stuff
>>
>>55516260
job security
>>
>>55516646
From the beginning.
>>
>>55516660
Do you have any material recommendations?
>>
File: wide.png (224 KB, 1051x621) Image search: [Google]
wide.png
224 KB, 1051x621
Working on an automated manga redrawer using machine learning. Spent awhile slogging through research papers and scrapping data but hope to have a working application before 2017.

Pic related some data I collected.
>>
>>55516767
Nice, when did you start on this project?
>>
>>55516651
w-what?
>>55516767
Looks cute but I miss the purpose.
>>
>>55516701
Any programming book worth its salt will talk about data structures as well. If you're just beginning, then don't worry about getting a book specifically about data structures until you finish the book about your chosen language.
>>
>>55516778
Early June.
>>55516817
Scanlating manga involves erasing the original Japanese text, which can destroy a lot of the artwork. The application's purpose is to automatically draw in the erased areas so everything looks right.

The same tech has applications elsewhere. [spoiler] Like uncensoring hentai[/spoiler]
>>
best way to check if certain key combination is pressed in python?. Like if I want to terminate the program when control+S is pressed, what would be the best way?
>>
>>55516942
>Scanlating
lol just learn Japanese already.
>>
>>55516010
I work on my school project.

I need to make a truck manager program with Windows Forms. The teacher sent us some basic UML diagrams to help us get started but we have to "contribute" to the diagrams or we get fucked.I am done with that tho I just need to make the code nicer and correct some mistakes.

I am having fun with this project.

I will post a webm when it is done.
>>
>>55516942
If that could help to get my rustle doujins uncensored faster, then it's a great application.
>>
>>55516977
Why not WPF?
>>
>>55516995
The next project will be made in WPF. I want to "impress" the normies with some fancy animations in the class next time.
>>
>>55516942
That actually sounds pretty useful assuming it can work consistently.

>>55516967
>lol just learn Japanese already.
I keep meaning to do that and end up starting/restarting cause I usually can't remember a lot of kana, let alone more than a handful of kanji or actual words.
>>
>>55516942
That's a pretty handy tool you're working on there.
>>
>>55516967
Don't have time for that when you're a starving grad student senpai.
>>55516979
Support for RGB pictures will come much later once I get it to work for monochrome pics
>>
Can anyone explain IDE wars? I don't get it.
>>
Waiting for feedback from my last chance at a job. Literally don't know what I'd do if I don't get it.
>>
>>55516817
If nobody but them knows what their code does, only they can maintain it. making them a valuable asset to the company
>>
I'm a new programmer currently working on a Chess program in Java. Please tell me how retarded this implementation is.

Space class. Children of this class are the pieces. The only difference the children have with this class is that they have a different default state. Squares on the board are changed by changing the string variable "state" to the name of the piece and color of the piece.

public class Space {
private String state;
private String color;

public Space() {
state = "blank";
color = null;
}



Then we have this object which takes in the game board as its only parameter. It then has many methods to check whether the move is valid. Which I have not created yet.

public class RuleChecker {
public Space [][] board = new Space [8][8];

public RuleChecker (Space[][] rboard) {
board = rboard;
}
public boolean isMoveValid(int x_start, int y_start, int x_end, int y_end) {
String start = board[x_start][y_start].getState();
String end = board[x_start][y_start].getState();
return true;
}


Is this shit idea of implementing chess board? Or is it good enough?
>>
>>55517722
Now I get it, seems like a dirty trick but necessary. ty
>>
Are there any offline interpreters, compilers, and/or IDE's for non-shit languages (acceptable languages include scheme, C, C++, C#, Python, and Clojure) I can download on a jailbroken ios device or unrooted android device to program on the bus?
>inb4 use a laptop
Laptop has shit-tier battery life and I'm too poor to afford a new one at the moment.
>>
>>55517884
>Programming in public
>Programming on a mobile device
>Programming without a keyboard
Are you serious? Do you really think you will be able to accomplish anything like that?
>>
>>55516171
Edgy faggot
>>
>C still doesn't have a standard half float implementation

Who the fuck thought this was a good idea?
>>
>>55517971
There are talks of adding "short float" to the next standard.
>>
Why is SQL so comfy?

>>55516103
>>55516127
>>55516144
>>55516171
>C programmers
Why do people use C if they're not writing a systems program?
>>
>>55517939
I'll be able to learn a bit, fuck around in scheme and read some SICP. I also have an old Motorola droid phone I could use.
>>
>>55518012
It's probably the worst possible programming environment you could impose on yourself.
Seriously, don't even bother.

>>55517991
Why wouldn't I use C?
Who says that I'm not writing a "systems program"?
>>
Any programs I should download for programming in C besides Vim and GCC?
>>
sicp 1.8

https://sukritkalra94.wordpress.com/2014/05/26/sicp-exercise-1-8-newtons-method-for-cube-roots/

is this pajeet totally stupid or am i?
>>
>>55517991
>Why do people use C if they're not writing a systems program?

Because they are 1337
>>
>>55518054
GNU Make
Valgrind
>>
>>55518071
Thanks pal.
>>
>>55518064
What's wrong? They used two accumulators?
>>
>>55518071
+gdb
>>
>>55518064
It's you.
>>
>>55516010
why the frickin frick does this not work?

someStruct.member1 = &someStruct.member2;


member1 is a pointer to the type of member2
>>
>>55518394
show complete code
>>
>>55518114
>two accumulators
enlighten me

>whats wrong?
i was reading it in public setting :/
in reality what i got was nearly identical to his:
(define (good-enough? guess x)
(< (abs (- (improve guess x)
guess))
(epsilon x)))

(define (epsilon x)
(* x .0001))


>>55518372
it tends to be
>>
File: gcc-logo[1].png (63 KB, 800x599) Image search: [Google]
gcc-logo[1].png
63 KB, 800x599
I'm working on a threaded SDL2 application and despite working on Linux, I would also like to compile it on Windows.

Should I use std::thread or SDL's threads? Couldn't find an answer to this by Googling, but I heard thread support on MinGW wasn't very good. If possible, I would like to be able to compile the same code on both systems without too many system specific macros and what not.
>>
>5000 lines of python code written over a 3 months
>need to convert to c++ in less than a week
Fucking kill me now. I dont even feel like Im writing c++. Its more like Im writing a compiler for python.
>>
>>55518512
std::thread, no question
thread support will be just as bad on MinGW no matter which one you choose, but you'll want to compile with VC++ on windows for any "serious" program anyway
>>
>>55518469
Is that some racket?
>>
>>55518512
GCC supports threading from 5.1.0 as far I remember, if you can't afford that then just go for SDL, it'll work out of the box on almost every major platform.
>>
>>55518534
Doesn't MS's compiler now inject some sort of call-home stuff into all binaries? Its not a huge program so I would prefer not to install VC++ just for it and since MinGW I've already used.

Maybe this library would fix the issue? https://github.com/meganz/mingw-std-threads
>>
>>55518580
I can use any version as long as it's available so suppose I'll go for that. Thanks!
>>
>>55518596
>Doesn't MS's compiler now inject some sort of call-home stuff into all binaries?

Think they just got rid of the telemetry stuff in the last update of Visual Studio.
>>
>>55518546
more or less
im running drracket using
#lang planet neil/sicp

that said i imagine that snippet would run in any number of parentheses-laden languages
>>
>>55517971
>half floats
Who the fuck thought that was a good idea?
>>
/dpt/ used to have an IRC channel with tripfags and shit. Some guy was making an OS.

Is it still out there?
>>
>>55518323
Debuggers are a meme.
>>
>>55516767
What is a manga redrawer?
>>
>>55518852
i think he basically means one of these:
http://waifu2x.udp.jp/
>>
How do I make my own programming language? All the ones I learned suck. I want to make a good one.
>>
>>55518931
http://www.buildyourownlisp.com/
>>
>>55518931
Designing and implementing a programming language is actually quite difficult, you know.
Anyway, in essence, all you need to do is to write a compiler or interpreter for your language, but there are many steps to that.
Read the dragon book.
>>
>>55518959
Forgot to mention: no memes.
>>
>>55518983
Not the guy you're responding to, but does the book get better?
I never got past tokens, i just felt like he was spewing a whole lot of complicated needless bullshit for something that is actually quite simple.
>>
>>55518996
If you want to write a compiler for something, and have it not be total trash, you probably want to read the literature.
A lot better computer scientists that you have been developing those compiler techniques.
>>
File: wat.png (64 KB, 1248x693) Image search: [Google]
wat.png
64 KB, 1248x693
>>55518983
I don't need to start from scratch. I want to start from Scheme. It's the almost perfect programming language.

I'm just not sure what to do or where to start. I've read all these fucking papers, had some deep realizations but I still feel like I haven't learned shit. These fuckers keep talking about abstract shit but they never quite tell me how they did it, much less how to do it.

I just want to have a fucking system bootstrapped.

>>55518996
Lexical analysis really is a simple concept. Want me to explain it to you?

>>55519025
Papers like pic related? Yeah right.
>>
>>55519067
What the fuck are these magic runes.
>>
>>55519067
>Want me to explain it to you?
Yes please sensei.
>>
>>55519088
You split a meaningless input string into meaningful chunks (lexemes), so that you can parse them easier.
The end.
>>
>>55519171
I already understood that.
If anything I need help with code generation and (i think) AST's.
>>
why is python so weird about referencing variables in functions

like I try to get one variable without importing it into my function and that fails, so I set a function to make a global and that fails too because 'it hasn't been set yet' (even though it has). and booleans don't work at all for that
stupid
>>
>>55519235
>so I set a function to make a global
Like how? (Pseudo) define the variable globally and then change it in the function?
>>
>>55519088

You have a stream of stuff.

In 95% of cases, the stuff is just characters. In 4% of cases, the stuff is raw bytes. The 1% is there because really you can tokenize anything.

In the stuff stream, chaos reigns. As far as anybody can tell, it's a bunch of random bits, in dire need of structure. So, what do we do with them? We lexically analyse them.

One by one, we take stuff from the stream. Let's call them things.

We compare them against what we expect will be in the stream. These expectations are higher abstractions that you define. For example, an identifier.

If it's successful, we have a partial match against one specific kind of abstraction. Once we eat up enough things to fully match that abstraction, we have a result. A token. A lexeme. The basic unit of parsing.

Lexical analysis reduces the complexity of the input stream. It digests a lot of characters and returns one token with the string inside. If the lexer expects an identifier matching [a-zA-Z], when given asdfg it will match the a, consume the sdf and finish at the g, and return a single <identifier "asdfg"> token. It drastically reduces the size of the input of the parser proper.

Notice that it maps a stream of characters into a stream of tokens. The structure is still linear, regular. It stops being linear when the parser runs. The context free grammar naturally produces output of higher complexity.

Code generation maps this high complexity parser output back into a low complexity, linear form. Byte code, assembly code... What is it if not a linear stream of bytes?

>>55519087
It's been days and I still can't even begin to decipher this shit.
>>
>>55519271
Can you go into more detail about code generation and specifically register allocation?
>>
>>55517756
Uh, wouldn't it be better to have the pieces calculate the squares to which they are allowed to move than to have a singleton class for checking rules? Like a piece.getMoves() method?
>>
>>55519352
Movement restrictions are not just determined by the piece, they are determined by the state of the board that is my logic.
>>
>>55519327
Read the dragon book.
It goes into that.
>>
>>55519363
You could pass information about the board state to the method, or you could get the possible moves from the piece and then have the board class determine if these moves are illegal (due to blocking, moving off the board, whatever). A huge global controller class is best avoided when designing a program, I've heard.
>>
>>55519264
yes
works in other languages, you know

you can have entire statics classes for this sort of thing

I've just been using enumerate() as a very hackneyed way around it for now
>>
>>55519327
One of the most based examples of code generation is this this assembler for the NES CPU:

http://ahefner.livejournal.com/20528.html

It's a nice read. Abstraction by abstraction, he synthesizes higher level constructs on top of the assembly code. It's as if he was working his way bottom-up from the assembly to the abstract code of the AST in his head.

Code generation is to do the opposite. You have a complex AST. You want to compile it down to a linear output vector.

The trick is that all those higher level AST nodes compile down to some lower level node in some defined way. You take some nodes and generate some output. You take a C function node and a __fastcall annotation node and you decide you're going to use fast call ABI calling convention. You proceed to recursively compile the rest of the function, but you've gotten rid of that fastcall node. Now it's not two __fastcall + function nodes anymore. It's just one fast-call-function node. You compile that node and you find a lot more that become simplified into lower level constructs until it's just one single whole bunch of bits.

And just like that, a procedure eventually gets mapped into some architecture's assembly code according to some calling convention.

Register allocation really matters when you want to optimize the shit. We say there's pressure on the registers when there are more variables than registers. They get written onto the stack to make room for new variables and get restored later, as if a function had been called without a jump. Slower but hey it works.

So now we have the problem of deciding which variables get mapped to which registers. I don't know much about this. Apparently there are some NP-complete graph algorithms that are doable for static compilation but suck for JIT because slow.
>>
What is wrong with this insertion sort? Code is not working.

public static int [] inSort (int[] array)     {

for (int j = 1; j < array.length-1;j++) {
int key = array[j];
int i = j - 1 ;
while (i > 0 && array [i] > key) {
i = i - 1;
array [i+1] = key;
}
}
return array;

}
}
>>
>>55518512
>C++
>>
>>55519826
Jesus christ, how horrifying.
>>
File: 1466037585055.jpg (89 KB, 698x840) Image search: [Google]
1466037585055.jpg
89 KB, 698x840
>>55519826
>>
Why is Prelude so shit?

>>55516103
Keep overflowing the stack, Hime!
>>
>>55519826
this kills the programmer
>>
>have error compiling massive git
>find someone with the exact same error as me
>edit: fixed it
>doesn't say how
>>
>>55519924
>>55519872
I don't get it? What did I do wrong?
>>
>>55519937
You code formatting makes literally no sense.
>>
>>55519937
If you can't see the problem, then you should consider to stop programming forever and kill yourself.
>>
>>55519941
>>55519942
he gets this response every time he posts his code
and every time, he pretends like he doesn't see it coming
just ignore
>>
>>55519826
the problem is your braces aren't sorted

public static int [] inSort (int[] array){

for (int j = 1; j < array.length-1;j++) {
int key = array[j];
int i = j - 1 ;
while (i > 0 && array [i] > key) {
i = i - 1;
array [i+1] = key; }
}
return array; }
}

see?
>>
>>55519942
What is the problem?
>>55519941
Has nothing to do with me, the copy pasting and putting it on 4chan did that. The brackets line up with each other. Usually. Put your eye on the left bracket, and then move it in a straight line down, when it hits a right bracket, thats where it ends.

The last bracket was copy pasted as an accident, and ends the whole class.
>>
>>55519975
>the copy pasting and putting it on 4chan did that
lol sure thing bby
>>
>>55519826
(You)
>>
>>55516010
C++
If I want to implement sort of an registering program, and the user have to enter his gender and current place of living, should I use <map> or <set> or should I use any other fuctionality provided ?
>>
File: notepadd++.png (14 KB, 759x347) Image search: [Google]
notepadd++.png
14 KB, 759x347
>>55520006
>>55519984
FUCK YOU!!! THIS IS HOW NOTEPAD++ TAUGHT ME HOW TO INDENT!!! IT WORKS FOR ME!!!
>>
>>55520028
Map will do.
>>
>>55520037
> using notepad++
kill yourself, you're literally worse than atom and vim users combined
>>
>>55519975
>the copy pasting and putting it on 4chan did that. The brackets line up with each other.
That doesn't explain why most of the actual statements aren't indented, and why "i = i - 1" and "array [i+1] = key" aren't at the same indentation.

Please don't format your code in some retarded special snowflake way.

>>55520037
Jesus christ.
>>
>>55520061
>>55520052
plz stop you'ing him
plz
>>
>>55520061
You've not actually posted any arguments. You're just mad that I'm not doing things your way. Logically, it's easier to read this than it is to read what someone else posted. You literally just look down and see what that block of code encompasses.
>>
>>55516010
watching marco polo
>>
File: 1467925043578.jpg (41 KB, 530x520) Image search: [Google]
1467925043578.jpg
41 KB, 530x520
>>55520067
>>
>>55520067
(You)
>>
File: fragezeichen yui.png (94 KB, 396x395) Image search: [Google]
fragezeichen yui.png
94 KB, 396x395
How expensive is creating pthreads really?

If I'm doing a time sensitive operation (musical sample playback) on a raspberry pi, should I consider making a thread pool?

Are there any good articles about this?
>>
>>55520105
make a thread pool
>>
>>55520105
talk about premature optimization
just do the thing.
if there's no problems, then you're done
if there's a problem, Then you can look into it.
>>
>>55520105
you go for one solution and make it easy to change it later if the need arises
shit like this comes with experience
>>
>>55520125
>Le premature optimisation meme
That is no excuse to write slow software.
Creating threads are fucking expensive. So much so, that the overhead of just creating a thread can kill all advantages of using that thread in the first place.
If you're going to use threads a lot, use a pool.
>>
I'm reading from a textfile and I want one of the fields to serve as literal variable names within the REPL (it makes sense, don't say "that's supid"). This is the function I'm using to define a string as a variable name:

(define (defff var val)
(let ((qvar (string->symbol var)))
(eval (list 'define qvar val))))

#;1> (defff "anus" 888)
#;2> anus
888


Looks good? Is there any macro magic that can do it better?
>>
>>55520215
>do more work and add more complexity to solve a problem that likely doesn't even exist
You are the Master Memester.
>>
>>55520118
>>55520215
do you have any good resources about writing thread pools the correct way?
I'm a bit confused about how to reuse them and change their arguments without creating the thread anew
>>
>>55520256
I'm not him, but I imagine every milisecond counts in music.
>>
>>55517884
>>55518012
It's not free, but the app Lisping is actually quite good. If there's any language that benefits from a touchscreen interface (or is even remotely usable on a touchscreen) it's Scheme.
>>
How do I statically compile with g++? I'm sick of these shitty dlls cluttering up my programs.
>>
anyone have any good material on making a driver? I want to make one to read memory from another process without being detected by VAC.

Can't find anyone posting about making drivers for non hardware related things online.
>>
>>55520272
your solution wont even be any good if you design it before you determine if the problem exists

and if it turns out that the straightforward approach would have been just fine, you've wasted your time and made your code more complex for nothing

perhaps even worse, it might turn out that the problem does exist, but your "solution" doesn't solve it
now you've wasted your time creating a solution that you now have to throw away because you designed it before understanding the problem
>>
>>55520052
atom is literally the most retarded piece of software ever.

Look at """the benchmarks""" did compared to some other (even ones with more features) editors and see how shitty it is.
>>
File: 1442620447676.jpg (41 KB, 500x404) Image search: [Google]
1442620447676.jpg
41 KB, 500x404
I just don't understand makefiles at all.
>>
I have a Python script that counts up an integer variable 1, 2, 3, 4 , 5 ... so on.

I want certain numbers to sometimes be disabled. Example: In an attempt to make it skip the number two and go "1 and immediately 3, 4, 5 so on" I created a true/false flag boolean in a "if else" statement that goes "int + 1" if it's false (false being that I've effectively disabled that integer). Immediately, this works. You will see it go 1 and then 3.

However, a strange thing happens now. You'd think now that it would count "1, 3, 4, 5 ..." because I made it skip 2, but now it'll count 1, 3, 3, 4, 5 ..." in this scenario. The "else" statement is making changes to the variable integer for that moment, but it doesn't reflect a permanent change to it and I'm baffled. How do I make the integer truly skip a number and not repeat itself?

else:
oink = oink + 1
#this is what I'm using right now
>>
>>55520504
me, for some reason the indentation in the code tag is off, but I assure you "oink = oink + 1" is indented appropriately in my script.
>>
>>55520229
that's stupid
>>
>>55520504
You should post the entire loop.
>>
I'm trying to solve euler - 17 using C and my program is giving me a segmentation error message which doesn't make sense to me..
I tried to figure out what i'm doing wrong here but no dice..

Can any of you nice anons from /dpt/ please help me out?

http://pastebin.com/Bcf455dT

https://projecteuler.net/problem=17
>>
>>55520476
What problems are you having with them?
>>
>>55520563
int N2Lcount(int n){
...
N2Lcount(n/100)
}

infinite recursion = segfault
>>
>>55520563
Your first mistake is to use the garbage that C is. Your second mistake is that your recursion executes several dozens of thousands of times and blows up the stack.
>>
>>55520606
At the moment I have this purely because it also works in cmd
g++ glfwwindow.cpp -o glfwwindow.exe -static-libgcc -static-libstdc++ -lopengl32 -lglew32 -static- lglfw3 -lpng -lz

But I can't figure out how to statically compile so I can get rid of all these dll dependencies that are cluttering up my applications and I also can't figure out how to include this resource.o file using a makefile which, with cmd, it is enough to just tack resource.o onto the end of that command line.

Also when I actually try to look up how to use makefiles it is just, entirely different from the way I am doing it.
>>
>>55516476
preaching to the choir m8. My power level has dropped significantly bellow 8000
>>
>>55520549
This is complicated. I'm using Blender Game Engine (which uses Python for scripting).

The "counting" is actually a logic node setup that increases the integer variable with a keyboard input. The script calls that variable and controls aspects of the game based on that variable.

This isn't the entire script, but here's where all the magic happens.

flag = False

def movingFunction():
obj = bge.logic.getCurrentScene().objects['Menu']
#oink is the integer variable
oink = obj['Weapons']
own = sce.objects['Cursor']
if oink == 0:
own.worldPosition.y = power1.worldPosition.y
own.worldPosition.x = power1.worldPosition.x
if oink == 1:
if flag == True:
own.worldPosition.y = power2.worldPosition.y
own.worldPosition.x = power2.worldPosition.x
else:
oink = oink + 1
if oink == 2:
own.worldPosition.y = power3.worldPosition.y
own.worldPosition.x = power3.worldPosition.x
oink == 2
if oink == 3:
own.worldPosition.y = power4.worldPosition.y
own.worldPosition.x = power4.worldPosition.x

print(oink)
movingFunction()


Here's what happening. The cursor moves around a list of items.
>>
File: 1459381343488.png (355 KB, 403x345) Image search: [Google]
1459381343488.png
355 KB, 403x345
>>55516476
>Working on a project
>Get burned out
>Take a break for a day
>Come back
>Completely forgot how my program works and my annotations are gibberish
>>
>>55520623
>>55520621
hey, but I'm pretty sure recursion should not occur more than 3 levels for any given case..
ie a three digin number like n=999..

C is not the most convenient language, I agree but thats what my university started off with so thats all I have
>>
>>55520666
I was with you up until "forget how my program works"
>>
>>55520682
Yes, forgot how it works. As in completely forgot how all of my code was functioning toward my end goal. Not "forgot what I wanted my program to do when it was finished".
>>
>>55520689
>//what are comments
>>
>>55520689
>>55520682


>>55520710
>comments
get out
>>
>>55520663
What's the purpose of oink == 2 on the 20th line? The comparison will have no effect at all. You're also increasing a variable that's pulled from someone else, so the modified one is probably only kept within a single execution, then when it fires another time, it pulls oink anew. You'd need a counter outside the function if I'm correct about what you're trying to achieve.
>>
>>55520675
>hey, but I'm pretty sure recursion should not occur more than 3 levels for any given case..
Well you're wrong.
>>
>>55520710
Are you retarded?

>>55520713
Jesus Christ I expected more from /dpt/, I don't know why. When I said "forgot how it works", I meant my comments were gibberish and as a result I forgot what half the fucking values and functions and shit were supposed to be doing. Holy shit guys.
>>
>>55520734
>>55520682
>>
>>55520734
>I meant my comments were gibberish and as a result I forgot what half the fucking values and functions and shit were supposed to be doing. Holy shit guys.

How the fuck am I supposed to know what you meant, if you don't declare your variables?
>>
>>55520764
>>55520756
Okay I'm out. You cheeky devils are taking me for a ride.
>>
>>55520774
Don't let the door hit you on your way out, you wankpuffin.
>>
>>55520774
If you forget how your code works after a one day break then you probably don't belong here
>>
>>55520721
>What's the purpose of oink == 2 on the 20th line?

That's certainly doesn't belong there, went ahead and removed it. It must've been something I fucked with while trying to get that to work. I deleted it and still have the same "double number" issue.

>the modified one is probably only kept within a single execution, then when it fires another time, it pulls oink anew.
>You'd need a counter outside the function if I'm correct about what you're trying to achieve.

hmmm, how do I do this? What can I possibly put at the end of the script to say "make oink become the new value of oink?" I just tried "oink = oink" and that does nothing.
>>
>>55520732
uhh.. okay...?
thanks!
:(
>>
>>55520809
Something like this:
flag = False
index = 0

def init():
index = bge.logic.getCurrentScene().objects['Menu']['Weapons']

def move():
if index == 0:
...
elif index == 1:
...
elif index == 2:
...
elif index == 3:
...

move()


Where init should be called only once to load the number of weapon objects. I'm still not sure if that's correct though because I've no idea what exactly the weapons object is, how is it created, if it's modified at all and how/when does the movingFunction execute.
>>
>>55520843
>if elif if elif if elif
>index == 0
>index == 1
>index == 2
>>
>>55520337
bump this guy, I would like some keywords, bread crumbs to start with.

On drivers and undetectable memory editors/scanners.
>>
>>55520861
Your point being? I'm not going to write a lookup table or completely overhaul the structure of the original code snippet to make it confusing for someone who might not understand it just to represent an idea.
>>
>>55520884
my point being it's terrible code
>>
>>55520882
sure
look up how to make something run in "ring 0"
that's all you need, really
>>
>>55520902
It's like you missed the entire point of my post, congrats on lacking brain cells. Tell it to the guy who initially asked for help instead.
>>
>>55520902
everything is terrible code. you're terrible code
>>
>tfw your portfolio will never be this good
http://neuroid.co.uk/2015/
>>
>>55520984
http://neuroid.co.uk/2015/js/nrd.min.js
Are you fucking kidding me?
>>
>>55520984
That's fucking stupid. Not only it took a while to load, but it also took a while to navigate while with pointless animations just to present 4 or so short paragraphs of text.
>>
>>55520984
I can't fucking read the text on the third slide, Nice fucking going m8.
>>
>>55521015
Not that I disagree with you, but it is his portfolio, or CV. It's supposed to be extravagant to advertise himself and what he can do
>>
>>55520984
http://neuroid.co.uk/lab/cub/
pretty neat for 200k.
>>
>>55520663
if you want to expand that function maybe do something like this instead of constantly using 'if':
def foo(param):
own.worldPosition.y = power+param+.worldPosition.y
own.worldPosition.x = power+param+.worldPosition.x
def test():
obj = bge.logic.getCurrentScene().objects['Menu']
oink = obj['Weapons']
own = sce.objects['Cursor']
dict = {0:'foo(1)', 1:'foo(2)', 2:'foo(3)', 3:'foo(4)'}
try :
oink = int(oink)
if oink <= len(dict):
eval(dict[oink])
print oink
else:
print '[Error] oink is greater than 3'
except ValueError :
print '[Error] oink is not an integer'
>>
>>55521058
>eval
>>
>>55521058
>concating an undefined variable and an integer
that's not how reflections work lol
>>
Is eval cancer?
>>
>>55516010
I'm at a research group at college, I'm making a program that interacts with the autopilot of an unmaned helicopter and gives it orders and shit.
It's fucking hell.
>>
>>55521190
http://europe.newsweek.com/artificial-intelligence-raspberry-pi-pilot-ai-475291?rm=eu

You could learn a lesson from these guys m8
>>
>>55516767
Neat.
>>
>>55521253
That's fucking funny, we're going to mount the program into a Raspberry Pi too.
>>
>>55520337
Windows, Mac or Linux?
>>
>>55521274
yes
>>
>>55521061
still better than using 'elif' 100 times
>>55521078
I know, but you get the concept. Also how am I supposed to write fully working code without the rest of the program?
>>
>>55521283
believe in the you that believes in the program
>>
>>55521283
use the heart of the code
>>
>>55517217
>cause I usually can't remember a lot of kana
Use Anki, there are tens of kana decks; or if you don't want to, there are kana quizzes online which you can just bash until you get it right. Reading kana also helps of course.
>>
>>55521274
windows
I have tried a few things but still not too much info i can find.
>>
>>55521280
Yes what? which of them do you want to develop drivers for?
>>
>>55517756
I see no benefit in separating RuleChecker from Board. RuleChecker would kinda be the next level of abstraction you'd take if the rules of a game can change from instance to instance; but if it's just Chess, I don't think it's necessary to go there with RuleChecker.

>>55517939
>>55518012
>>55518045
Incidentally, this is how John Carmack learned Scheme (going through SICP on his phone while commuting).

>>55519087
A more general answer: each bar defines an inference rule for a type system (that's what the T-.... usually means). To read it: if the stuff above the bar is true, then the stuff below the bar is also true. The |- symbol means "can prove". So S |- epsilon ~~> (s, F, [s-->F]) means that S can prove whatever that thing on the right-hand side means (S is probably some kind of environment or context).

That box right at the top tells you that every judgement is of the form S |- r ~~> (s,F,T): that is, everything below the bar in the judgement looks like that.

>>55518996
While neat and historically important, I feel that the Dragon Compilers book is flawed in ways. For example, it spends far too long on parsing (which might make you think parsing is a significant part of writing a compiler; it's not).

I recommend:
Engineering a Compiler, Keith D. Cooper and Linda Toczon

If you're a more hands-on person you could try:
Modern Compiler Implementation in Java by Andrew Appel

Writing a compiler for a simple, type-safe C/Java-like language is not too hard. Neither is doing one for functional programming, but the operational semantics for those tend to be quite minimal and to fully grasp what's happening you'll want to know a bit of lambda calculus + type theory.
>>
>>55521354
Then this:

https://msdn.microsoft.com/en-us/library/windows/hardware/ff557573(v=vs.85).aspx
https://github.com/Microsoft/Windows-driver-samples

If you are using Windows 8 or higher, you will need to disable signature check at boot.
>>
>>55521392
By the way, when I say "S can prove P" it means that S can prove P using the inference rules you're defining.

To start you off, you usually have some axioms i.e. inference judgements with nothing above the line. The conclusion corresponds to things that are true for every environment.

Or, more likely for researchers in the area, their type system is grafted onto some other more simpler type system (e.g. basic simply-typed lambda calculus) and assume you know how all those rules work and that you can use 'em.
>>
>>55521058
updated version:
def foo(param):
vars()[power+str(param)]
own.worldPosition.y = vars()[str(power)+str(param)].worldPosition.y
own.worldPosition.x = vars()[str(power)+str(param)].worldPosition.x
def test():
obj = bge.logic.getCurrentScene().objects['Menu']
oink = obj['Weapons']
own = sce.objects['Cursor']
dict = {0:'foo(1)', 1:'foo(2)', 2:'foo(3)', 3:'foo(4)'}
try :
oink = int(oink)
if oink <= len(dict):
eval(dict[oink])
print oink
else:
print '[Error] oink is greater than 3'
except ValueError :
print '[Error] oink is not an integer'
>>
I'm reading some Go code and I found a function that does this:
router := NewRouter()
log.Fatal(http.ListenAndServe(":8080", router))


Now I don't know Go but is there any reason why router would be a variable instead of NewRouter() being called as the second argument for ListenAndServe? Does Go forbid that?
>>
>>55521481
>vars()[power+str(param)]
sorry doesn't belong there
>>
Seriously why is the syntax for makefiles so fucking bizarre?
>>
>>55521361
Not the guy that replied to you, I am the original guy that asked the question.

I want to develop the driver for windows.
>>
>>55521518
>>55521420
>>
>>55521492
>Now I don't know Go but
...

https://godoc.org/net/http#ListenAndServe


And yes you absolutely can use a literal instead of assigning it to a variable if you like being obtuse

package main

import (
"fmt"
"net/http"
)

func main() {
http.ListenAndServe(":8080", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "etc...")
})
}
>>
>>55521852
Thanks champ.
>>
Rate my collision detection library.
Link: https://github.com/BobbyRaduloff/freebox2D
>>
>>55518012
I'm currently learning lisp through land of lisp and the common lisp repl on my droid. It sucks a lot, but I have so much free time at work where I can't have a laptop. So just do what you can.
>>
>>55521910
"""library"""
>>
>>55516103
Keep overflowing the stack, Hime!
>>
>>55516260
code is meant to be read by people and only incidentally executed by the machine.
>>
I'm going through the first chapter of the C programming language book and need ideas for a while loop exercise. Any suggestions?
>>
>>55518394
because Type != *Type
>>
>>55522174
/g/'s favourite, write a fizzbuzz.
>>
haskell a goat
>>
What book would you recommend to transition from java to c#.
>>
>>55522174
long long i = 0;
while(1)
{
if (i == 10) { exit; }

i = i + (int) 1.0

putchar(i);
}
>>
>>55517991
Because most schools only teach C, C++, Java (or C#), "functional" languages, and dynamically typed languages.

Students think C and C++ are the only compiled language with "value types" (no "boxing" everything with pointers) that doesn't need a garbage collector. C++ is so horrible these days that it's almost like the committee wants people to stop using it, so they pick C.

Most of them never learned Pascal, Basic/VB, Fortran, PL/I, Ada, or any other "traditional" programming languages.

>>55520675
>C is not the most convenient language, I agree but thats what my university started off with so thats all I have
>>
I'm working on a home automation/siri-thing with a Whatsapp contact as a frontend. This is my first project in python and I think I really hate python. :3
>>
How can I apply a function to something before binding it to a name with an IO string in haskell?

example:
value <- getString
newvalue = removeslashes value


instead how can I do
value <- removeslashes getString


in one line?
>>
>>55522911
value <- removeslashes . getString
>>
Haskell is so comfy

most of the time
>>
>>55522911
r <- reverse <$> getLine
>>
>>55523017
this works, thanks, but what is going on with the <$>? I know what $ does but not <>
>>
>>55523044
<$> is fmap
he's mapping reverse onto IO
>>
>>55522911
Haskell is disgusting.
>>
>>55523044
<$> is a synonym for fmap.
fmap :: Functor f => (a -> b) -> f a -> f b

As you can guess fmap takes a function and applies it to the value insight the functor f and then wraps the result in f again. Because every monad is also a functor we can use fmap in the IO context.
>>
>>55523119
disgusting
>>
>>55523119
what in the name of fuck is a "Functor"
>>
private boolean rotationDirty = true;
protected float getPitch(){
return (rotationDirty = false)?rotationMatrix.getRotation(rotationQuaternion).getPitch():rotationQuaternion.getPitch();
}

does this evaluate the expression in the brackets and then sets the boolean false? or am I missing something?
>>
File: 1468194246618.jpg (32 KB, 480x480) Image search: [Google]
1468194246618.jpg
32 KB, 480x480
>>55523068
How's your java pen and paper programming course going pajeet?
>>
>>55523152
a type & data constructor which can be mapped over

basically something you can fmap
>>
>>55523155
It sets the boolean to false, making that expression return false, and then goes to rotationQuaternion.getPitch();
>>
>>55523177
so much for that elegant one line expression
>>
>>55523195
Yeah, don't try to be clever, just write it like a normal human being.
>>
File: 1466329334062.jpg (24 KB, 258x263) Image search: [Google]
1466329334062.jpg
24 KB, 258x263
>>55523195
>elegant
>>
>>55523206
condensing a getter witha condition to only 1 line is pretty elegant in my opinion
>>
>>55523152
Well, it's a concept from category theory. In Haskell it's type class which requires instances to implement the function fmap.

List and Maybe e.g. are instances of Functor

(+1) <$> [1,2,3]        -- [2,3,4] 

reverse <$> Just "Hello" -- Just "olleH"
reverse <$> Nothing -- Nothing
>>
>>55523225
if (cond)
x;
else
y;
// multiline


if (cond) x; else y;
// elegant single line
>>
>>55523241
Im sorry but if and else on the same line is ugly as fuck. I use (nested if necessary) (boolean)?x:y constructs. that's just beautiful.
>>
>>55523152
It's a structure preserving mapping between categories. It is similar to a homomorphism.
>>
>>55522679
Can I second this?

I know a fair amount of java, would like to learn C# as well. Does anyone have any books or online resources to recommend?
>>
>>55524071
https://msdn.microsoft.com/en-us/library/67ef8sbd.aspx
https://msdn.microsoft.com/en-us/library/aa288436(v=vs.71).aspx

It's like you're not even trying.
>>
>>55522194
Why won't this compile without
resources/
before resources.o.

CC=g++
DIRECTORIES=-Iresources
GNU=-static-libgcc -static-libstdc++
CONTEXT=-lglew32 -lglfw3
PNG=-lpng -lz
glfwwindow: glfwwindow.cpp resources/resource.o
$(CC) -o glfwwindow.exe glfwwindow.cpp resources/resource.o $(GNU) -lopengl32 $(CONTEXT) $(PNG) $(DIRECTORIES)

Shouldn't it be picked up by including DIRECTORIES?
>>
>>55524170
I'm assuming because make works from the directory you run it from, so it can't find the file unless you specify the path relative to your cwd
>>
>>55524170
beats me
creating makefiles is a job for computers not people
>>
>>55524170
>>55524208
Didn't read your post thoroughly
The -I switch only picks up include files
>>
>>55524217
this desu, fuck makefiles
>>
>>55524170
No, -I is for headers.
>>
>>55524208
So does -I only work for #include then? Is there no way for me to scope to that directory without including the filepath every time?
>>
>>55524170
just use cmake m8
>>
>>55524244
Yeah, you'll want to use -L for directories with library files
>>
File: wall.jpg (371 KB, 1200x1200) Image search: [Google]
wall.jpg
371 KB, 1200x1200
import time
import os

dirdl = '/home/Anon/Downloads/'
dirp = '/home/Anon/Pictures/'
dirv = '/home/Anon/Videos/'
dird = '/home/Anon/Documents/'
dirm = '/home/Anon/Music/'

dirs = [dirp, dirv, dird, dirdl, dirm]

while True:
time.sleep(60)
for u in dirs:
os.chdir(u)
items = os.listdir(u)
for i in items:
if i.endswith('jpg') or i.endswith('png'):
os.rename(u + i, dirp + i)
elif i.endswith('webm') or i.endswith('mp4'):
os.rename(u + i, dirv + i)
elif i.endswith('mp3'):
os.rename(u + i, dirm + i)
elif i.endswith('pdf') or i.endswith('epub'):
os.rename(u + i, dird + i)


fucking noob here, made this to auto organize my files, put in autostart, works in the background all the time. so much time saved
>>
>>55524252
Cancer
>>
>>55524252
>Just use something that will make the process even longer and more convoluted
>>
>>55524301
maybe if you're stupid
>>
>>55524285
That's pretty neat-o.
>>
>>55524330
He is correct, what >>55524301 said happens even if you are smart.
Maybe actually get a brain and learn to use makefiles.
>>
>>55524347
no thanks im not a masochist
>>
>>55524330
>Trading one confusing syntax for another confusing syntax that is functionally identical but with an added layer of convolution
Thread replies: 255
Thread images: 22

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.