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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 321
Thread images: 35

File: 443.png (389KB, 934x1000px) Image search: [Google]
443.png
389KB, 934x1000px
What are you working on, /g/?

>>58141853
>>
File: karen haskell.png (818KB, 1280x719px) Image search: [Google]
karen haskell.png
818KB, 1280x719px
Functional Programming Thread:
>>58141396
>>
>>58147122
I am so glad you all have your own containment threads now
>>
>>58147122

>HaskLEL
>>
File: 1476854844528 (1).png (726KB, 952x1064px) Image search: [Google]
1476854844528 (1).png
726KB, 952x1064px
>>58147128
>>58147136
why are you so rude?
>>
There's nothing wrong with functional programming, but Haskell is a meme with no real world uses unlike JavaScript.
>>
>>58147178
>Haskell is a meme with no real world uses

I'll probably never use Haskell as long as I'm alive but that simply isn't true.
https://archive.is/NUsFz
>>
>>58147178
Javascript isn't functional, let alone functional

Uses of Haskell:
https://github.com/Gabriel439/post-rfc/blob/master/sotu.md
>>
>>58147212
I would call JavaScript a functional programming language, it has lambdas and first class functions.
>>
>>58147243
You mean like most other mainstream languages?
>>
>>58147243
>>58147246
*mainstream imperative OOP languages
>>
>>58147118
I'm working in a Ogre3D game
>>
Starcraft Broodwar API using BWAPI
http://www.starcraftai.com/wiki/Main_Page

I'm not joining any competition though. Just for the fun of it and it's a great project to discover shits where I can use Java 8 features like streams and lambdas.

By the way, if any of you guys are interested in creating one of your own BW AI, maybe we can have a general thread one day and have our bots fight each other?
>>
How do I pass a pointer to an array as a TEMPLATE argument in C++
>>
>>58147334
If you would like to know how to best use lambdas feel free to visit the functional programming thread
>>
>>58147334
Sounds nice
>>
>>58147118

Still on the very same Substance text parser.

It works very well now, with a much leaner class structure and all the complex mechanics hidden from the user.

On the other hand, my BufferedReader refuses to process the last lines for some reason ;____;
>>
>>58147405
yeah, it is. lots of interesting problems here like unit management, base layouts, etc.. not to mention the attack and defense strategies.
also, code architecture is key since you need to track a lot of states especially when you really get to the mid to late game
>>
>>58147460

have you read any books on the topic, or do you improvise and look problems up whenever they arise?
>>
>>58147469
no, i am not reading any books on the subject right now. most of the times I just solve them on the best way I think of.
Like for base layouts, I made it to build non-training buildings (supply depot, engineering bay, etc) farther from the base chokepoint and put the training buildings (barracks, factory, etc) closer to the chokepoint.

My next task is to have my bot to expand to the nearest resource field so it can mine there too.
>>
>>58147402
yeah, but the thing is that I don't know the syntax of those languages so I really have a hard time understanding the codes there
>>
>>58147538
well just ask if you think it could be improved
>>
>>58147401
<thing **>
>>
(It's the anon from previous thread who rewrote a Python script in C++ and it turned out to be twice as resource intensive.)

I figured out the reason, turns out I was indeed retarded but in the wrong way.
The dumb mistake was fixed and now the program it runs ~10 times less instructions than my Python script.
>>
File: aoc.2016.day.24.jpg (418KB, 915x577px) Image search: [Google]
aoc.2016.day.24.jpg
418KB, 915x577px
>>58147118
Friendly reminder that there's only one more day left for 2016's Advent of Code.

Have you collected your 48 stars yet?

>tfw still need to finish Days 11 and 17
>>
>>58147905

>requires a social media account
>>
>>58147918
just use your 4chan account, tripfag
>>
>>58147918
>tripfag complaining about needing to sign up for accounts
>>
File: 1.png (222KB, 1786x929px) Image search: [Google]
1.png
222KB, 1786x929px
I can't fucking believe you faggots actually get paid more than minimum wage to code

coding is simple
>>
>>58147943
>dicking around in a computation simulator that's not even Turing-complete
>hurr durr it's so ez
raffing @ u
>>
>>58147943
holy shit, can i buy that program from you? i need it for my CS dissertation
>>
>>58147938

A tripcode is not an account.
>>
>>58147918
Just get a Github already you faggot.
>>
>>58148041
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>
>>58146999
I'm interested in what you've written to end up slower than python.

It's probably a typical example of where python manages to be faster because the programmer has been less specific because he was using rather high level. So the python compiler could do more.
>>
>>58147943
I can't either. Some of the people I work with would serve the company better if they just got me coffee all day or sucked my dick when I asked.
And even then my work isn't hard.
>>
>>58148068
That's why I say it was a dumb mistake in this post >>58147899.

I made a pretty big change in my C++ program and forgot to adjust some things to it. This led to the program doing way more work than I want it to, without me noticing it.
So I fixed that, and now it's all good and very efficient.
>>
>>58148042
I have one. I don't want to use it to sign into some random site, and I don't want to encourage the behavior of requiring an account sign in.
>>
File: IMG_0763.jpg (2MB, 3264x2448px) Image search: [Google]
IMG_0763.jpg
2MB, 3264x2448px
I'm writing an interpreter for my extremely autistic thread based assembly programming meme language.

Compiler and decompiler are already done.

Anyone here done something similar and care to share it?
>>
File: images.jpg (5KB, 262x192px) Image search: [Google]
images.jpg
5KB, 262x192px
>>58147212
>Javascript isn't functional, let alone functional
DANG NICE ONE HAHA

HIGH FIVE ME BRO WHOOOOAAAAAAAA
>>
>professor says he "understands about 70% of closures"
Am I supposed to be impressed or something?
>>
>>58148104
Puzzle inputs are randomly generated per user to prevent cheating. It's not like it's some attempt to sell you out to Big Data.
>>
>>58148117
thanks
>>
>>58147212
JavaScript has closures, and the fake kind.
>>
File: 76.png (17KB, 900x900px) Image search: [Google]
76.png
17KB, 900x900px
>>58148104
Ah yes, your individual actions influence sites with thousands of users.

You're like those carbon footprint nuts who walk to work to prevent climate change.
>>
>>58148117
>>58148138
o/
>>
>>58147905
I need to finish Part 2 of Day 9 and both parts of Day 11, otherwise I got everything else done. Too mach pathfinding this year imo, recycled like 5 times.
>>
>boost
Boy this seems nice but I didn't know error reports from compiling could be so useless till I started to try using this.
>>
>>58148219
>I didn't know error reports from compiling could be so useless till I started to try using this.
That's a general C++ problem, not just boost.
>>
>>58148219
Try forgetting to pass an argument to a thread, or not passing a reference when it's required. In response you'll get a pile of trash that has nothing to do with your program.
>>
>>58148219
>error messages
Yeah templates will do that.
>>
I really like Visual Studio, but the way they organize solutions/projects is horrible.
>>
>>58148219
I've gotten to the point to where I just avoid using boost.
>>
>>58148641
Still far better than eclipse or xcode.
>>
>>58147243
That's because you don't know what a functional programming language is :^)
>>
>>58148310
>arduino
>zero print statements in my program
>also zero libraries used that should print shit
>things are printing for some reason
>they're actual words, there are counting variables, etc
>eventually realise I forgot to return on a function
>it was jumping into the last program that the last person had written at that point since it was still in flash
I'm not sure what was more impressive, that it actually worked, or that the compiler didn't warn me.
>>
>>58148707
JS is a functional language. Case closed.
>>
>>58148727
Then so is C#
>>
>>58148757
Yes since 3.5
>>
C/C++ compilers for Windows: What are my options?
There's MSVC and MinGW. Are there any other serious contenders?

There's Clang, i think, but i haven't really understood what that is exactly. It's some kind of compiler backend that still needs MSCV as a frontend, i think.
>>
>>58148811
write your own compiler like I do right now.

Flex & Bison my friend, Flex & Bison
>>
>>58148811
MSVC is okay on Windows, it caught up with the standards and the compile times are pretty fast but the linking takes minutes sometimes, as opposed to almost instant in GCC on the same project. MinGW is basically GCC package for Windows with some extras, and you've confused clang with LLVM, LLVM is the backend, clang is a frontend for LLVM, it's pretty good but I still prefer GCC because it just werks.
>>
>>58148824
But why?

I mean, sure it would be a good learning experience, but there is no way it would be even close to practically useful compared to the big name compilers.
Speaking for myself, of course. I'm not trying to criticize what you're doing.
>>
>>58148824
reminder that Haskell is easily the best language for writing compilers
>>
>>58148854
LLVM doesn't work well on windows right now.
>>
>>58148854
So clang/LLVM exists for Windows, completely independent of MSVC?
>>
File: IMG_20161224_130748074.jpg (710KB, 2500x1406px) Image search: [Google]
IMG_20161224_130748074.jpg
710KB, 2500x1406px
This werks for me now :-)

Now just gotta figure out how to dim that shitty display or just turn it on and off. Fucking china shit has literally no documentation ;_;
>>
>>58148862
I was joking, it's just my assignment, cool one though. When I was using windows MinGW was alright.

>>58148865
>he fell for the Haskell meme
>>
File: f28822725.png (446KB, 401x401px) Image search: [Google]
f28822725.png
446KB, 401x401px
>when cmake generates your makefiles and they build without problem
>on windows
>without cygwin
>>
>>58148906
it's not a meme, Haskell is the nicest language to write your own language in
>>
File: 1479320936498.jpg (75KB, 612x612px) Image search: [Google]
1479320936498.jpg
75KB, 612x612px
>>58148895
Hot weather you have these days.
>>
$ ruby -e 'p [][0]'
nil


discuss
>>
File: ruby irl.png (266KB, 339x589px) Image search: [Google]
ruby irl.png
266KB, 339x589px
>>58149005
>ruby evaluates to nil
seems about right
>>
>>58148909
>pic very related
>>
>>58148912
You misspelled OCaml.
>>
>>58149081
ahahaha

seriously though
no
>>
File: bioshock.jpg (709KB, 1080x1920px) Image search: [Google]
bioshock.jpg
709KB, 1080x1920px
Soft like VLC with a music suggestion (C#)
Hard.
>>
fuck C++
>>
>>58148912
I've done this and I strongly agree. Then again, writing yet another interpreter/compiler is the only thing Haskell is good for, since the performance doesn't matter and IO is non-existent.
>>
I'm pretty sure this isn't what this thread is made for, but can anyone tell me which part of this statement unity3d is bitching about (I'm a total c# newb btw):
>>else {
>> while (fire == true && >>magCount > 0) {
>> magCount -= 1;
>> WaitForSeconds (recoil);
>> }
>> }

magCount is a public int, recoil is a public float and fire is a public bool.

I get an error of "Expression denotes a `type', where a `variable', `value' or `method group' was expected"
>>
>>58149151
it bitches about >> in >>magCount
>>
>>58149160
I added the >> in the post, the actual code is:

else {
while (fire == true && magCount > 0) {
magCount -= 1;
WaitForSeconds (recoil);
}
}
>>
>>58149170
Going to need some context. Also, use
 tags
>>
>>58149196

unity3d c# script, applied to my gun model, *very* early stages, its the else{} that's giving me problems (removing it fixes it).

:code
using UnityEngine;
using System.Collections;

public class shootScript : MonoBehaviour {

public bool fire = false;
public int magCount = 10;
public bool auto = false;
public float cooldown = .5f;

void Start () {

}

void Update () {
if (fire == true && auto == false) {
if (magCount > 0)
magCount -= 1;
fire = false;
}
else {
while (fire == true && magCount > 0) {
magCount -= 1;
WaitForSeconds (recoil);
}
}
}
}
:stopcode
>>
>>58149224

using UnityEngine;
using System.Collections;

public class shootScript : MonoBehaviour {

public bool fire = false;
public int magCount = 10;
public bool auto = false;
public float cooldown = .5f;

void Start () {

}

void Update () {
if (fire == true && auto == false) {
if (magCount > 0)
magCount -= 1;
fire = false;
}
else {
while (fire == true && magCount > 0) {
magCount -= 1;
WaitForSeconds (recoil);
}
}
}
}
>>
File: ?.png (7KB, 120x120px) Image search: [Google]
?.png
7KB, 120x120px
How do i converting Pi to binary?
>>
>>58149410
you can't it's impossible
>>
>>58149410
Define precision and convert.
>>
>>58149425
you can design an algorithm that gives you pi if you give it a precision
>>
>>58149452
nope that's a myth
>>
>>58149224
>>58149234
undefined variable recoil.
I'm not familiar with unity, is update called every tick?
what problems you have with it?
what is it supposed to do and what does it do instead?
>>
Is it worth switching from VS 2015 to 2017 yet? For C# 7, more Xamarin integration etc.?
>>
>>58149481
It just won't start, and gives this error
>>
>>58149501
wait for the final, I used to use the RC versions, but then getting a clean final was a pain in the ass.
>>
>>58149473
bruh

in pic related, replace infinity with a number that would fit your precision requirements
>>
>>58149513
not true
>>
>>58149501
i tried xamarin in 2017 yesterday, boy was i getting lot of bugs, couldn't even start the emulator phone

wpf was working fine, console too
>>
>>58149522
it has been proven
https://proofwiki.org/wiki/Leibniz's_Formula_for_Pi

unless you don't believe in math...
>>
>>58149506
what error? did you try reading the error? did you try doing what the error message suggested?
>>
Guys, I am almost done!
But this passed every second object without extracting it, for some reason.

public void extractObjects (int amountOfObjects) {
int objectCounter = 0;
try {
String line;
String [] fields;
while ((line = flatfilereader.readLine()) != null && objectCounter < amountOfObjects) {
lineCounter++;
fields = line.split("\t");
if (fields[0].equals(classIdentifier)) {
currentEntry = manager.getExtractableObject(objectClass, fields);
this.database.add(currentEntry);
while ((line = flatfilereader.readLine()) != null && line.startsWith(subClassIdentifier) && subClassIdentifier != null) {
lineCounter++;
fields = line.split("\t");
currentSubEntry = manager.getExtractableObject(subObjectClass, fields);
currentEntry.addSubEntry(currentSubEntry);
}
objectCounter++;
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
System.out.println("Stopped extracting " + objectClass + "(s) at line " + lineCounter + ", currently " + this.database.size() + " in the database.");
try {
if (flatfilereader.readLine() == null) {
System.out.println("File ended at line " + lineCounter + ". Reader will be closed.");
flatfilereader.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}


Otherwise, I feel very content with the architecture. The factory pattern helped me a lot.
>>
I posted here about how to deal with mediocrity in my company the other day. My coworker has found a solution.
We've started using a quality management system called sonarqube. It tells us all kinds of metrics about our code that I hardly even knew were possible. It tells everyone the same things I tell them in code review, but it's automated and people can see every instance of the problem.
>>
>>58149572

what kind of metrics can such a tool give you?
reminds me of the Java reflection package.
>>
File: Capture.png (3KB, 1012x32px) Image search: [Google]
Capture.png
3KB, 1012x32px
>>58149566
>>
>>58149588
so look at line 24. what do you see?
>>
>>58149588
go to line 24 column 33 and show us what's there
>>
>>58149610
>>58149611
thats the WaitForSeconds (recoil); it can be a number instead of recoil, it doesn't change anything
>>
>>58149634
And now we look at the documentation and read
>WaitForSeconds can only be used with a yield statement in coroutines.
>>
>>58149634
you use WaitForSecond incorrectly
>>
>>58149582
Duplicated blocks, code smells, vulnerabilities, bugs. It's compatible with Istanbul for coverage, which we use for test coverage calculation. It calculates overall days of tech debt given all these factors. We're just getting started with it, so I'm not really sure what else it can do.
>>
>>58149648
how would I make the script wait for a second before continuing
>>
>>58149663
Make a timer.
>>
>>58149663
read the documentation of waitforseconds, it tells you how.
>>
Does anyone have better, preferably non-retarded names for these variables?

ExtractableObject currentObject;
ExtractableObject currentSubObject;
ExtractableObject currentSubObjectsSubObject;


Every object may have subObjects, which, in turn, may have subObjects of their own, subObjectSubObjects, so to say ...
>>
>tfw to smart to use Java
>tfw to smart to be employed
>>
>>58150087
>tfw too smart to study
>>
>>58150078
curr, sub, subsub
>>
>>58150078
x
xy
xyz
>>
>>58150078
x
xx
xxx
>>
>>58150209
did you write a complex algorithm to get that or did you type it manually?
>>
>>58150078
o
o->o
o->o->o
>>
How's D?
>>
>>58150436
You should ask you're mom, she seemed to enjoy mine last night ;)
>>
>tfw to intelligent to write code
>>
>>58150453
Get off /g/ dad, you're embarrassing!
>>
>>58150233
#include <stdio.h>
#include <malloc.h>

int main(int argc, char **argv)
{
printf("How big should the tree be? ");

unsigned count;
scanf("%u", &count);

char *str = malloc(count + 1);
if (str == NULL) return 1;

for (unsigned i = 0; i < count; i++) {
str[i] = 'x';
str[i+1] = '\0';
printf("%s\n", str);
}

free(str);

return 0;
}
>>
>>58150539
why the fuck would you save it in a string
>>
>>58150548
Why not?
>>
File: 9.jpg (48KB, 492x492px) Image search: [Google]
9.jpg
48KB, 492x492px
What does /dpt/ think of Lua?
>>
Hello, gurus.

Please explain to me why making every single action in my program run through the unified debugging method is wrong and why i should kill myself.

 public static class TryHard
{

public static void This(Action x, string Message = "Some kind of error has occured")
{
try
{
x();
//MessageBox.Show(text: "all fine!");

}
catch(Exception e)
{
MessageBox.Show(text: Message + Environment.NewLine + Environment.NewLine + e);
}
finally
{ }
}

}


And then use for any action that potentially can fail.

TryHard.This(() => SQLEngine.ImagePath());


So why would it be a bad practice?
>>
>>58150685
Nice library, shame about the language.
>>
>>58150685
Great as an embedded scripting language
Very easy to integrate in C and C++ programs
Low memory footprint

Would be my first choice to make a program scriptable
>>
>>58150689
only catch exceptions that you know how to deal with.
if you can't or it's not in your power let it throw.
>>
File: 1461961138736.png (539KB, 1027x621px) Image search: [Google]
1461961138736.png
539KB, 1027x621px
Can I use image macros/reaction images found on 4chan in my GPL licensed project?
>>
>>58150741
no.
>>
File: PepeDiskMark for GNU_087.png (43KB, 650x354px) Image search: [Google]
PepeDiskMark for GNU_087.png
43KB, 650x354px
>>58150741
Pepes are only allowed in Pepe Public Licensed programs
>>
>>58150748
Why?

>>58150754
Lel, is it compatible with GPL?
>>
>>58150754
Pepe wouldn't fall for the GNU meme, Pepe understands the importance of protecting your hard work with proprietary licences.
>>
>>58150754
>>58150792

Frogposters should be shot.
>>
File: heavy_metal.jpg (177KB, 1280x693px) Image search: [Google]
heavy_metal.jpg
177KB, 1280x693px
Best free IDE? I've used Intellij IDEA and Eclipse at work. I definitely like Intellij better but it's the Enterprise licensed one. Is the free one worth it?
>>
>>58150784
Because posted images don't state their license, so you can't just use them.
The base image might belong to someone else and then sues the shit out of you.

If you can't be sure about anything using a license that allows you to reuse it you can't use it.
>>
File: 1477791124045.png (49KB, 400x389px) Image search: [Google]
1477791124045.png
49KB, 400x389px
>>58150784
>Lel, is it compatible with GPL?
No.
PPL is like GPL except that Normies are not allowed to use the software or look at the source code.

>>58150792
The PPL protects from use by Normies
>>
>>58150807
For what I use it for (Scala) I haven't really noticed a difference between the Community and Enterprise editions of IDEA.
>>
File: 123.jpg (109KB, 908x572px) Image search: [Google]
123.jpg
109KB, 908x572px
How is the third number in this example 8 and not 4?
>>
>>58150891
9
>left up right down
(no change)
>left
8
>>
>>58150891
Starting from 9 where we left off.

Left to 8
Up to 5
Right to 6
Down to 9
Left to 8

It even says in the image you posted.
>>
>>58150891
Left from 9, 8. Up from 8, 5. Right from 5, 6. Down from 6, 9. Left from 9,8.
>>
>>58150920
>>58150925
>>58150926
fuqq i thought it reset to 5 after each number
>>
>>58150935
why would it do that?
>>
>>58150935
Anyway what's the actual challenge?
Given the input, calculate the number?
>>
>>58150891
Thank you for doing Advent of Code.
>>
#include <stdio.h>
#include <stdbool.h>

int main(int whatever, char **fuck_you) {
for (int i = 1; i <= 100; ++i) {
bool printed = false;

if (i % 3 == 0) {
printf("Fuck");
printed = true;
}

if (i % 5 == 0) {
printf("Butt");
printed = true;
}

if (!printed) {
printf("%d", i);
}

printf("\n");
}

return 0;
}


So do I get the job??
>>
>>58150958
Fuck off
>>
>>58150965
no
>>
File: 1437637097586.png (169KB, 656x400px) Image search: [Google]
1437637097586.png
169KB, 656x400px
>tfw can't ever talk about my projects in /dpt/ because afraid of getting doxed and harassed
>>
>>58151002
It's safe here anon, tell me about it
>>
>>58149005
you're accessing a non existing index on an empty array. what is there to discuss?
>>
>>58151000
Why not?
>>
>>58151002
Go for it man, I know I'd love to see what people here are getting up to.
>>
>>58151015
are you the same guy who made >>58150539?
>>
File: CcuYraMXIAE5Yn6.jpg (79KB, 600x788px) Image search: [Google]
CcuYraMXIAE5Yn6.jpg
79KB, 600x788px
Help.
I am trying to sort lots of files in a folder, each file has random numbers followed by an underscore(2535642_2015-01-10.jpg)
I want to make a folder with the random number and move all the files that match that number to the same folder.
Will this code work.
 $FileList = Get-ChildItem -Path F:\Pictures;

foreach ($File in $FileList) {

$File.Name -match '^(.+?)_';

if ($matches) {

$Destination = 'F:\Pictures\{0}' -f $matches.folder;

Move-Item -Path $File.FullName -Destination $Destination -WhatIf;
}
$matches = $null
}
>>
>>58150944
I lack reading comprehension ignore me

>>58150957
http://adventofcode.com/2016/day/2
pretty much

>>58150958
I'm enjoying it so far, only did the first challenge last year and just now got reminded of it this year itt
>>
>>58151043
why?
>>
>>58151039
No
>>
>>#ifdef DEBUG not working
>>check project properties
>>it is _DEBUG
why do they do this
>>
>>58151071
>why?
Just sorting files...
>>
c++

since when is non member
 begin(myvector) 
a thing?
>>
>>58151110
Since C++14.
>>
>>58151089
So you can use
-D_DEBUG
in your gcc args
>>
>>58151043
where does $matches come from?
>>
>>58150998
why?
>>
>>58150685
It was developed in my university. I think that's pretty cool.
>>
>>58151257
HUEHUEHUE Found the brazilian
>>
>>58151043
gci *_*.jpg | % { $dir = ($_.name -split "_")[0]; mkdir -force $dir; mv $_ $dir}
>>
>>58151257
Do Brazilians not know how to used 0-based indexing or something?
>>
>>58151002
me too
>>
I'm writing a 3D game engine in C. Its going to be used in by my classmates in a school project next year.

The entity system is component based in such a manner that entities are just a collection if indices to component arrays. Components are structs of pure data that remember their owning entity's index and some other stuff (like what mesh to use for 3D model components, etc.)

I was thinking of adding a sort of a "script" component to provide users a way to make an entity do something every frame - it would have a function pointer and some user defined variables. But some scripts require more variables than others, and I have to store those variables somehow. Of course, its the user who defines the script, so should I simply ask the user for a pointer to a script's data upon component/entity creation? That way the user would have to manage the memory of any scripts they use instead. Any ideas or examples of how real engines have done this kind of thing?
>>
data Ins = U | L | R | D
deriving (Read)

runIn n i =
case (i, n) of
(U, x) | x `elem` [1,2,3] -> x
| otherwise -> x - 3
(D, x) | x `elem` [7,8,9] -> x
| otherwise -> x + 3
(L, x) | x `elem` [1,4,7] -> x
| otherwise -> x - 1
(R, x) | x `elem` [3,6,9] -> x
| otherwise -> x + 1

runIns = drop 1 . scanl (foldl runIn) 5

instructions = (map.map) (read.pure) ["ULL", "RRDDD", "LURDL", "UUUUD"]

code = runIns instructions
-- [ 1, 9, 8, 5 ]
>>
>>58151271
>>58151287
no bully pls
>>
do you fa/g/s find in excruciating to read other people's C++ code?

is there a coding job where you never have to do that?
>>
>>58151364
Become a java developer.
You never have to read other peoples C++ code.
>>
How do you make one of the MessageBox buttons in WPF (for example button Yes) to open hyperlink in browser?

I literally can't find it on stackoverflow or anywhere

MessageBoxResult result = MessageBox.Show("Do you want to open link?", MessageBoxButton.YesNo, MessageBoxImage.Asterisk);

switch (result)
{
case MessageBoxResult.Yes:
//WAT DO HERE
break;
case MessageBoxResult.No:
break;
}
>>
>>58151364
Get a real job, pajeet.
>>
>>58151421
System.Diagnostics.Process.Start("http://google.com");
>>
Kraut with the Substance Object parser here.

I actually did it! I could still improve my program through l33t hack0r skillz like reflection or generics, but the core functionality is very solid and the code far, far shorter and discernable than before.
>>
>>58151364
Most /dpt/ professionals have highly paid Haskell jobs
>>
>>58151468
Ur an insult to the real hackers worldwide like me. Try learning some avr and Intel and arm and related ABIs I hacked so many things ur not even close to my level, kid
>>
>>58151433
Why is Process.Start in something called Diagnostic? Starting a process doesn't seem like a diagnostic to me.
>>
>>58151496
*teleports behind your IP mask*
*hacks your CPU core*
pssst, nothin personnel, kiddo
>>
>>58151542
actually that's pretty personally
>>
File: leluezs2.jpg (84KB, 508x409px) Image search: [Google]
leluezs2.jpg
84KB, 508x409px
>>58151477
>highly paid
>Haskell
>jobs
>>
>>58151509
Because you get diagnostic info of other process with the Process class.
Starting one is just a minor functionality.
>>
>>58151433
Holy fuck i am literally retarded, i've seen that answer on stack but my string for link was below actual method that starts messagebox, that's why it didn't work
>>
>>58151554
it's a joke

a joke

there are only java jobs
>>
>>58151542
I have at least a quad core. And systemd iptables and the latest kernel set up on 3 of them so you've got a lo g way to.compromising myy entire system. skid
>>
>>58151280
I did it!
$FileList = Get-ChildItem -Path F:\Videos\Screenshots;

foreach ($File in $FileList) {

$File.Name -match '(?<folder>.*?)(?:_)';

if ($matches) {

$Destination = 'F:\Videos\Screenshots\{0}\'-f $matches.folder,$matches.filename;
mkdir -Path $Destination -ErrorAction SilentlyContinue
Move-Item -Path $File.FullName -Destination $Destination;
}

}
>>
Anyone know how to go about declaring a global const variable, then initializing it in some function?

int foo[8];

void Init_foo(void){
for(int i = 1; i < 8; ++i)
{
//calculate stuff
foo[i] = result;
}
}

//How do I make foo const from here on out?


Is it possible at all, and is it different in C/C++?
>>
.>>58151578
>>58151554
>>58151477
You are all pathetic. I'm a mathematician, I make 300k a year and use exclusively haskell for my job.
>>
>>58151667
You can't.
>>
>>58151667
const variables can't be changed.
they are, as their name says, constant.
>>
>>58151676

Let me guess ... You do not use an IDE and write your code directly into your UNIX shell?
>>
>>58151676
I bet you also take dick up the butt for your shitty job
>>
>>58151695
>write your code directly into your UNIX shell?
>using an OS.

B L O A T
L
O
A
T
>>
>>58151695
No, I use emacs. Anyone doing anything serious in a computer uses vim or emacs. All other editors and ides are stupid memes.

>>58151699
I take dick because I enjoy it.
>>
File: jh.png (602KB, 963x720px) Image search: [Google]
jh.png
602KB, 963x720px
Never had a github account before.

Why should I create one, /dpt/? Everyone seems to have one these days.
>>
>>58151707

>using an electronic device for programming
>not building a mechanic Turing machine with typewriter output

plebs
>>
File: mathphd.jpg (34KB, 640x427px) Image search: [Google]
mathphd.jpg
34KB, 640x427px
>>58151676
>I'm a mathematician, I make 300k a year
sounds like a starting salary desu
>>
>>58151731
It's like SourceForge ten years ago.
>>
>>58151693
Yes, that's why I have it as int first. But what I was asking is if it could be const, maybe by a cast or something after the call to the initializer, as I don't want it to change afterwards.

>>58151691
So what then could be a good practice for this? Do I just run a printf and initialize the results manually? It kind of looks dirty that way.
>>
>>58151731
If you don't care about all the SJW shit they support it's useful for managing your git repos. GitLab is also pretty great from what I have heard.
>>
>>58151741
I just graduated, senpai.
>>
>>58151731
Because your boss tells you to

literally the only reason
>>
>>58151761
const int foo = initFoo();
>>
>>58151768
a bunch of faggots put their shit on github to get jobs

maybe the jobs market now is too good but in the past it was a good strategy
>>
does /g/ religiously follow the ADT concepts and ideas?
I mean when you write a function that returns a collection of strings, do you do it like this?

return an abstract type
Collection<String> getNames()

or like this? return a specific type
List<String> getNames()

Set<String> getNames()
>>
>>58151788

/g/ doesnt know anything about programming, except /g/ memes
>>
What's the best alternative to github?
>>
>>58151804
I'm really good.
>>
>>58151808
what's wrong with github?
>>
>>58151808
gitlab
>>
>>58151808
bitbucket. it has private repositories for free
>>
>>58151787
>maybe the jobs market now is too good

doubt it.
i mean, it is not bad, (compared to basically every non-programming job) but it is not better than in other years.

the millenial normies may catch the drift and all go into IT.
>>
>>58151824
Aside from being operated by SJWs, hemorrhaging money, and on the verge of bankruptcy?
>>
>>58147122

moar like shit waifu thread
>>
>>58151835
>but it is not better than in other years.
I"m pretty fucking sure that it's much better than after the 2008 financial collapse

it took years for the economy to *kind of* recover

people who were graduating or looking for first jobs then went through hell
>>
File: Calculus of Maki Constructions.png (312KB, 452x355px) Image search: [Google]
Calculus of Maki Constructions.png
312KB, 452x355px
>>58151862
maki would use haskell
>>
Does github's SJWness affect your own personal projects?

For example, would I get into trouble if I uploaded a repo for a tower defense game based around the migration crisis, which involved defending Europe from waves of migrants?
>>
>>58151785
How do I do this with arrays?
>>
>>58151857
so don't work for them, it's still decently functioning service
>>
>>58148131
Have it take an email then.
>>
>>58151857
>hemorrhaging money, and on the verge of bankruptcy
False.

*IF* it was true, it would be a reason not to invest money on it, not to not create a free account and host your haskell hello worlds.
>>
>>58151667
>>58151761
int _foo[8];
const int *foo = _foo;


Then initialize _foo instead of foo.

I don't think this counts as "good practice" though
>>
>>58151868

oh, 2008.
im from germany, so I never experienced it that much.

the job market is worse than it was here. in the early 2000s, you would be hired on the spot if you could spell "Java" correctly.
>>
>>58151877
No.
>>
>>58151877
Yes
>>
>>58151911
>the job market is worse than it was here. in the early 2000s, you would be hired on the spot if you could spell "Java" correctly.
that was the doc com bubble?

> im from germany
of course it matters which country
>>
>>58151887
I'd rather not support SJWs at all.

>>58151892
Github operated at a $27 million dollar loss last year and as of September of this year they were $66 million dollars in the hole.
>>
>>58151936

as i said, we in western europe imported dotcom and 2008 from you guys, but it wasnt that much of a defining event.

im glad to hear that US developers are doing well. with your levels of salaries, i have no idea why pajeet and ivan arent doing your jobs, though.
>>
>>58149545
false
>>
How do you make several Messageboxes in WPF to not appear on top of each other but slightly moved, exactly like when errors in windows are not on top of each other but you can see a little bit of every messagebox error in the background?
>>
>>58152049
something like this
>>
>>58151945
>Github operated at a $27 million dollar loss last year and as of September of this year they were $66 million dollars in the hole.

Yeah dumbass, it's called expanding. It also received massive investment rounds increased it's market valuation. It's basically has a monopoly and is no where close bankruptcy.
You are a stupid memester that believe anything that is written on the internet and has no idea of how a business works.

Even if what you said were true, you dumb hacker-news poster, that would not be a reason not to use github.
>>
>>58150891
Phew
>>
>>58152114
very nice
>>
>>58152083
https://www.youtube.com/watch?v=a1Tf5uuGvjs
>>
>>58152083
>It's basically has a monopoly
far from the truth. github is strong amonsgt open source where it's mostly free repositories; doesn't bring any money but still costly.

in the enteprise, github has to battle with many contenders which are gaining grounds, especially gitlab.
>>
>>58151808
https://gitla.in/
https://gitgud.io/
>>
File: Untitled.png (77KB, 1166x702px) Image search: [Google]
Untitled.png
77KB, 1166x702px
>>58152185

GitLab certainly seems to have a more impressive corporate user portfolio.
>>
How do I output a variable amount of lines of the values of four variables with spaces in between to a file in Python? filename.write can't seem to take more than either one string or one variable, using the >> wizardry doesn't seem to work either, same problem.
>>
>>58152351
>a variable amount of lines of the values of four variables with spaces in between
What? Can you give an example?
>>
>>58152389
I need a set of values for Origin to plot, it should look like this:

0.0 1.0 -1.0
0.1 1.2 -1.5
0.2 1.4 -2.5
0.3 1.6 -3.0
0.4 1.8 -3.5

The first value in a line in my case will be the time of the step, the second the value of a function in this step, the third its derivative and the fourth the derivative of that derivative
>>
Quick pol on the future of /dpt/:

http://www.strawpoll.me/11949251
>>
>>58152434
srs

for n in range(totalLines):
file.write('{} {} {}'.format(lines[n].a, lines[n].b, lines[n].c))
>>
>>58152498
>No "Lisp" option
2/10
>>
>>58152498
>No emojicode option
Wha'chu doin boy
>>
>>58151877
>involved defending Europe from waves of migrants
DO ET
>>
#include <stdio.h>

void signed_test_long() {
long of, uf; // overflow, underflow

uf = 1;

while ((of = uf - 1) < uf) {
uf *= 2;
printf("%d : %d\n", uf - 1, uf);
}
printf("-------------------------------\n");
printf("TEST TYPE: long???\n");
printf("CAPACITY+: %20d\nCAPACITY-: %20d\n", of, uf);
printf("-------------------------------\n");
}

int main() {
signed_test_long();

return 0;
}

Output:
1 : 2
3 : 4
7 : 8
// exempting calculations, you get the idea
536870911 : 536870912
1073741823 : 1073741824
2147483647 : -2147483648 // stops here for exact same procedure with standard ints, 4 bytes appear to be allocated for those in this implementation
-1 : 0
// about 20 of these exempted
-1 : 0
-------------------------------
TEST TYPE: long??? // Suddenly, output after no change!
CAPACITY+: -1
CAPACITY-: 0
-------------------------------

Old post was deleted to me forgetting to do code tagging on the output.

Any of you wizards know what's up here?
>>
>>58152500
It worked brilliantly, thank you!
>>
Making an Object oriented UI lib for Lõve, with inspiration from IMGUI, so you can have static elements and also just display elements on the fly, seems pretty convenient to me but IDK.
>>
>>58152643
There's a Love2D binding for ImGui FYI.
>>
>>58152675

I wouldn't want to build the actual game GUI with monstrous if trees and endless function calls haha

Making my own seems like a nice exercise and a convenient way to get my needed functionality.
>>
>>58152755
>I wouldn't want to build the actual game GUI with monstrous if trees and endless function calls haha

oh gee I wonder how could it possibly be solved...
>>
anyone here actually used java reflection?
seems like awesome stuff.
>>
>>58151877
>For example, would I get into trouble if I uploaded a repo for a tower defense game based around the migration crisis, which involved defending Europe from waves of migrants?

The guy who made WebM for Retards got in trouble for the repo name, so I definitely believe that an open source game about killing muzzies is probably a no-go.
>>
>>58152767

What do you mean?

Like if I WANTED to use ImGui for everything, then I would need an IF to check if the game is currently in the menu, and if it is, then check which part of the menu it currently is in and if it's not then I'd need tons of logic to find out which parts of the UI to show and what pop ups to show and which inputs to wait for and whatever.

It would just result in REALLY ugly code, so yeah.
>>
Unpopular opinions:

>Haskell is shit and should not be taken seriously
>Lisp is useless and only used for third class text editor
>Anime is shit
>Maki is a slut
>Java is language of the future
>JS is a excellent choice for server-sde
>>
>>58152813
i think you should probably read some intro to programming before you dive deep into the water and try with a video game
>>
>>58152826

Lost caption:

>Unpopular AND wrong captions
>>
>>58152826
>>Lisp is useless and only used for third class text editor

I only disagree with this one, but there are a great number of people here who agree with you.
>>
>>58152833

Are you mentally retarded?
>>
>>58152849
no but apparently you are if you think the only solution for your problem is a giant nest of ifs
>>
>>58152826
>Haskell is shit and should not be taken seriously
>Lisp is useless and only used for third class text editor
>Anime is shit
>Maki is a slut
These are true.
>Java is language of the future
>JS is a excellent choice for server-sde
And these aren't.
>>
>>58152854

-_-
>>
File: 1481526738785.jpg (145KB, 600x631px) Image search: [Google]
1481526738785.jpg
145KB, 600x631px
>>58152826
>calls anime shit
>knows about drawn girls
Seems about true.
>>
>>58147118

php
>>
>>58152598
Undefined behavior.
>>
>>58152598
maybe the value after four billion was at least 20 times greater and it had enough of the procedure optimized so it just threw it in with the rest of the undefined behavior? In this case, possibly, "Incomplete definition of behavior"?
>>
>>58152936
So should I just leave it at that and not try to investigate further?

It's interesting that a long functions exactly the same as a standard int in this implementation, just without the easily replicated behavior of integer overflow.
>>
File: dpt_hime.png (518KB, 974x974px) Image search: [Google]
dpt_hime.png
518KB, 974x974px
/g/ cool kids club checklist

[x] hate OOP
[x] hate IDEs
[x] use only Haskell
[x] never produce actually useful software (this is important)
[x] wear knee socks
[x] tiling window manager
[x] dark-like-my-soul customized colors
[x] hate popular Linux distributions (because too intelligent for them)
>>
>>58152995
>too intelligent

3/10, learn your memes
>>
>>58152995
>two intellegente too check out in checklist
>>
>>58152995
>[x] wear knee socks
>[x] tiling window manager
How do I unlock these?
>>
>>58153050
Install Windows 1.0
>>
>>58152983
Signed integer over/underflow is undefined behavior, so compilers can generate code assuming it never happens (which both gcc and clang do), they could even turn that into an infinite loop.
>>
>>58153050
>[x] wear knee socks
https://www.amazon.com/Foot-Traffic-Bright-Multi-striped-Rainbow/dp/B00F2QD2NE

>[x] tiling window manager
https://wiki.archlinux.org/index.php/i3
>>
>>58153091
Do Rugby socks count?
>>
>>58153091

>I3, not Xmonad

lol, just install wangboos
>>
>>58153122
No.
>>
>>58152995
I had 7/8 5 years ago, and now I have 0/8. It's good to finally grow up.
>>
>>58152995
[ ] hate OOP
[ ] hate IDEs
[ ] use only Haskell
[ ] never produce actually useful software (this is important)
[ ] wear knee socks
[ ] tiling window manager
[x] dark-like-my-soul customized colors
[ ] hate popular Linux distributions (because too intelligent for them)
>>
I have 20 (You)s in this thread.

Feels good.
>>
File: hahafuckyou.jpg (104KB, 562x437px) Image search: [Google]
hahafuckyou.jpg
104KB, 562x437px
>>58149572
>2017
>discovered sonar
You must be kidding us.
>>
To: 58153364
Have one more
>>
What's a way of determining if something is a prime number or not?
So far I've got this, which can print out all numbers that are not prime.
for(int i = 2; i < 20; i++) {
for(int j = 2; j <= i/2; j++) {

if((i%j)== 0) {
out.println(i + " is not prime.");
break;
>>
>>58153454
>What's a way of determining if something is a prime number or not?
there is an entire field of mathematics dedicated to this
>>
[ ] hate OOP
[ ] hate IDEs
[ ] use only Haskell
[ ] never produce actually useful software (this is important)
[ ] wear knee socks
[x] tiling window manager
[x] dark-like-my-soul customized colors
[ ] hate popular Linux distributions (because too intelligent for them)

Only have these two because I really like i3 and I found a eva unit 01 theme floating around in my vim syntax themes and it's really fun to program in it.
>>
>>58153477
Is it in Nebraska?
>>
>>58153477
Really?
I'm trying to do a basic programming challenge which produces the sum of the first 1000 prime numbers.
>>
>>58152598
oh no wait I know what happened, it just caught itself going into infinity. Sorry, I wasn't read it right.

Yeah, it just caches itself going to infinity and dumps the cache instead, as a bypass, to doing something trivial to a program that still references the ram another way. Then before realizing fully that it is going into to inf loop, it feeds you zero instead ( probably from simply pulling out of the next bit in your register, the lazy greedy way ) and then without a flag for infinite loop decides to pull out and finish out its command structure.
>>
>>58153492
i like this joke
>>
>>58152767
do it once, in text and then create one huge differential equation that you could use to model the whole relationship between your data and the number of permutations of the standard form there could be and you got the standard for an object model but really it's a procedural map and it's still up to you to organize the signal with a sort model of trees and graphs anyway...soo...maybe game development isn't for you?
>>
>>58153502
The only way is to test all the possible factors up to n/2.

There are faster methods to verify if a number is most likely not prime.
>>
>>58153502
a number is prime if it has only 2 factors
>>
>>58153562
I was thinking of a way that safe primes could be used.

I figured it would help in a large sieve by giving a second thread of reference something to pull at while the larger primes were bogged up with calculation times.
>>
What's that copy-left license that is basically GNU but requires you to serve up source code if it's a server?
>>
>>58153502
I have a solution if you want me to post it.
>>
>>58153624
AGPL?
>>
>>58153562
That's what I'm doing in >>58153454
It can find numbers that aren't prime, but I don't know how to show if something is prime.
>>58153627
I'd rather learn and do it myself. Thanks though. Could you give me some advice about it though if possible.
>>
>>58153633
Yep, that's what I was thinking. Had a hard time finding it via google.
>>
>>58153638
>Could you give me some advice about it though if possible.
Not sure how spoilerish this is, but you can iterate through integers from 2 onward, finding those that are prime and putting them into the result, stopping after you've found 1000 of them.
>>
>>58151945
>literally being this afraid of a red herring """SJW""" boogeyman

when was the last time you left the house, Alex?
>>
New thread:

>>58153699
>>58153699
>>58153699
>>
>>58153638
If the challenge is to sum the first thousand then you don't need to do anything really clever, performance isn't going to be an issue.
>>
>>58153681
The problem is I don't know how to find a prime. I can find what isn't a prime but not the other way around.
>>
>>58149151
try yield return new WaitForSeconds (recoil)

I'm assuming this is in a CoRoutine
>>
>>58153751
You can determine whether an integer is prime by testing whether it is divisible by any of the integers smaller than it and greater than 1.
>>
>>58149663
CoRoutines
>>
>>58153751
ignoring the even numbers and numbers that are divisible by 3, which so often look prime, you can simply divideyour current numbers by each element in your list of primes. If the current number was larger than the a recent prime you can also negate what's known as a safe prime by excluding a, well known ,prime relationship and accessing the value by taking your recent prime multiplying it by 2 and adding 1. It would be like a blender.
>>
>>58154493
this safe prime situation being that you don't want to iterate one by one and instead want to jump to a new end and manage a several threads that would apply different rules on the current floor and ceiling index values and still allow some of the more heavy data to be managed in a timely manner while still searching for usable values with bogging up the flow of command and possibly creating new venctures for more threading purposes.
>>
>>58151364

Depends who wrote it. A lot of large opens source C++ codebases can be fairly neat and applying proper principles, but awkwardly designed overall. Academic C++ is typically terrible. Not because of poor design principles, but because they don't know how C++ works and don't care to learn. Sure, let's just go around passing vectors by value in a loop. Nothing wrong with that!

>>58150685

Shit type system, good performance if using Lua JIT.
>>
>>58154963
>Sure, let's just go around passing vectors by value in a loop. Nothing wrong with that!
>>
>>58151010
$ python -c '[][0]'
Traceback (most recent call last):
File "<string>", line 1, in <module>
IndexError: list index out of range
Thread posts: 321
Thread images: 35


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.