[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: 329
Thread images: 31

File: 1486667682897.jpg (31KB, 1008x720px) Image search: [Google]
1486667682897.jpg
31KB, 1008x720px
What are you working on, /g/?

Old thread: >>59511080
>>
First for anime picture
>>
>>59515417
I'm working on a
>>
File: download.png (5KB, 225x225px) Image search: [Google]
download.png
5KB, 225x225px
Hey guys, I wrote a keylogger in go. Can you guys r8?

http://pastebin.com/q8see1Ss
>>
>>59515465
> import (
> "github.com/jordan-wright/email"
>)
You can't make this shit up.
>>
c++ won't let me invent new primitive data types

gayest shit ever
>>
>>59515519
Welcome to trash
>>
>>59515465
go seems great for writing malware
>>
>>59515506
top kek

that shit might fly for internal stuff at google but even then it's sketchy
>>
>>59515506
I don't get it
>>
>>59515519
enum byte : unsigned char {}; // byte is a new integer type
byte b { 42 }; // OK as of C++17 (direct-list-initialization)
byte c = { 42 }; // error
byte d = byte{ 42 }; // OK as of C++17; same value as b
byte e { -1 }; // error
>>
>>59515536
>http://pastebin.com/q8see1Ss
It is really nice, but it is still in its infancy for malware. Hard to find good code for it.
>>
did you hear about that japanese machine that uses botnet code to color in line art
>>
>>59515540
He imports a library directly form master branch of a github repository. For some reason this is an accepted practice with Go.
>>
>>59515539
>>59515506
I don't think you guys realize how go works. You aren't actually getting it from the site.
>>
>>59515582
Lol, you don't know how go works.
>>
>>59515582
>He imports a library directly form master branch of a github repository
and what's bad about that
>>
>JSR-310/java.time use the word "Local" to mean "without timezone information", so actually not local
I've seen some stupid shit in my time, but jesus
I imagine the local bit was added at the end when someone noticed the specification was actually too reasonable by Java standards to be included in the core
>>
File: 4324535363.jpg (356KB, 1098x2986px) Image search: [Google]
4324535363.jpg
356KB, 1098x2986px
>>
File: 42699[1].jpg (55KB, 700x400px) Image search: [Google]
42699[1].jpg
55KB, 700x400px
hey guys how do i get an internship at blizzard? gimme tips and i suck yo dik
>>
Go, more like JEW.
>>
>>59515587
>>59515597
explain
>>
>>59515613
learn sepples
>>
>>59515587
>>59515597
Well I know Go caches repositories, but that's not the point.
>>59515598
There is not required version, so the next time author of the repository pushes a broking change or delete the repository clean deployment will fail. This is left-pad shit all over again.
>>
>>59515647
No you fucking retard. you can use "go get" the same way you use "pip install", so if there is and update to a repository, you would have to update it on your computer. You are not directly importing from github. The name of the module is just the same as the github site.
>>
>>59515688
So were do you specify the version of a package you need? Because whatever the source, without versioning the system is broken.
>so if there is and update to a repository, you would have to update it on your computer
Yeah, but what if I do a clean build on a new machine? I will have no other choice but to download the recent version from master, isn't it?
>>
File: fsharp256.png (3KB, 256x256px) Image search: [Google]
fsharp256.png
3KB, 256x256px
What does /g/ think of F#?

I want to do FP but I also want a job. Is this the best language to do that?
>>
>>59515784
Scala and Erlang / Elixir are more popular for that
>>
>>59515639
next tip please
>>
>>59515784
Very well paid, works with .NET, not nearly as trashy as Scala.

>>59515790
Nobody uses Elixir.
Scala is dying
>>
>>59515794
learn hardcore game/graphics programming with directx/opengl/vulkan. start by making simple games and tech demos. unless you want to be an artfag
>>
>>59515824
Directx is dead.
>>
>>59515824
I'm taking a c++ class right now. I'll look into what you said.

any ideas for projects that would look good on my resume?
>>
it's called directx 12 because only 12 programs actually need it
>>
>>59515794
Touch your monitor. It is warm, like flesh.
But itis not flesh.
Not yet.
>>
How long did it take you guys to get competent in your chosen language? What was your first language?
Learning JavaScript through Codecademy and I'm not sure if it's working and if I'm learning it properly or not.
>>
>>59515879
another tip pls
>>
Sooooooooooooooooooooooo anything?
>>
File: 0b2.png (349KB, 442x319px) Image search: [Google]
0b2.png
349KB, 442x319px
 while (true) {
try {
System.out.print("Enter prefix size: ");
prefixSize = in.nextInt();
break;
} catch (InputMismatchException e) {
System.out.println("Invalid input. Must be an integer.");
}
}


This prints "Invalid Input. Must be an integer." literally forever if a user inputs an incorrect answer.
Is System.in actually reading System.out? What the fuck?
>>
Daily reminder to
#include <conio.h>
>>
eh, gonna implement Djisktras in D lang because I'm bored and because I'm about to learn network layer routing in my networks class

question would something like -
https://dlang.org/library/std/container/binaryheap/binary_heap.html
be used as a priority queue?
>>
File: 1467721703978.jpg (95KB, 600x383px) Image search: [Google]
1467721703978.jpg
95KB, 600x383px
Learning operators in c# and unity

Next lesson will be on Equality operators.

Trying to get a good solid base in c# coding in unity so I can design my own games.
>>
>>59516025
Wheres the rest of the code? Have you considered using Integer.parseInt() instead of chucking an exception?
>>
>>59516035
>windows only
no thanks
>>
>>59515879
next one please
>>
>>59516058
ParseInt also throws a ParseException if the input is not valid.
>>
>>59516079
So why isn't the input valid?
>>
>>59516091
Because I'm trying to round the corners off of this program before I send it to a normie and I don't want it crashing if it gets given an incorrect input
>>
>>59515971
Remember to change your underwear daily.
>>
>>59516051
Looking at it, it's a Max Heap. Will probably want to use the 'negative' of distances then. Also note almost no libraries support decreaseKey op's, so you continually add the same node with 'lower' priorities instead (and keep track of 'visited' nodes in a set or something).
>>
>>59516078
Never pet a burning dog.
>>
>>59516110
Are diapers considered underwear?
>>
File: 1467721906943.jpg (153KB, 600x600px) Image search: [Google]
1467721906943.jpg
153KB, 600x600px
>>59516056
Example of some csharp I had to write for one of their game tutorials. Now that I know more of the c# coding I understand exactly what the hell I was typing and doing. This is a player crontroller script basically effecting the player character object in said game. From pick ups to the movement controller etc.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class PlayerController : MonoBehaviour {

public float speed;
public Text countText;
public Text winText;

private Rigidbody2D rb2d;
private int count;

private void Start()
{
rb2d = GetComponent<Rigidbody2D>();
count = 0;
winText.text = "";
SetCountText();
}

private void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector2 movement = new Vector2(moveHorizontal, moveVertical);
rb2d.AddForce(movement * speed);

}

void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag("PickUp"))
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText();
}
}

void SetCountText()

{
countText.text = "Count: " + count.ToString();
if (count >= 12)
{
winText.text = "You Win!";
}
}
}
>>
>>59516127
pleays use code tags or a pastebin
>>
File: 1467721273968.jpg (42KB, 500x333px) Image search: [Google]
1467721273968.jpg
42KB, 500x333px
>>59516135
Oh sorry new to /g/ so I didnt know about that, they in the sticky at the top?
>>
>>59516124
how is that going to get me an internship at blizzard?
>>
>>59516169
Think about it: if you pet a burning dog, chances are that you'll burn too and die, thus making it impossible for you to get an internship at blizzard.
>>
>>59516163
of course they are you fucking retard
>>
>>59516193
Salty oldfag
>>
File: 1467721043438.jpg (109KB, 640x630px) Image search: [Google]
1467721043438.jpg
109KB, 640x630px
>>59516193
Yep went and checked it before you got extremely uncool for a small thing.
>>
>>59516025
not sure how to explain it, but I guarantee it's some weird fuckery with the newlines and the way Scanner is reading them in from stdin.

try using
Integer.parseInt( in.nextLine() )  

instead
>>
>>59516060
The Open Watcom version works on Linux and DOS too.
>>
>>59516025
Does it ever output "Enter prefix size"?
>>
>>59516193
rude
>>
>>59516025
Enter prefix size: asdf
Invalid input. Must be an integer.
Enter prefix size: asdf
Invalid input. Must be an integer.
Enter prefix size: 4
1
11
21
31
41
51
61
71
81
91
101
Got it!

works on my machine.
>>
>>59516223
This did it. Thanks anon!
while (true) {
try {
System.out.print("Enter prefix size: ");
//prefixSize = in.nextInt();
prefixSize = Integer.parseInt( in.nextLine() );
break;
} catch (NumberFormatException e) {
System.out.println("Invalid input. Must be an integer.");
}
}


>>59516250
Might be a speed thing, then.
>>
>>59516122
well that's a pain in the ass. thanks for the advice btw!
>>
How hard is it to learn R?
>>
>>59516432
not that harRRrd
>>
>>59515465
If the goal is to key log someone, this would get caught by any antivirus. No obfuscation, no av evasion, no persistence etc. Otherwise, if an exercise, it's a good start.

If you're up for it, maybe have a go at dynamically loading and resolving dlls (like what malware does) so it doesn't reveal much information when the binary is checked with a tool like peid etc

Hook the keyboard functions (not sure if you have to have callbacks from C code to do this in go?). Maybe see if you can detect what hooks your antivirus installs and unhook them(most av will detect this without replacing the hooks or messing with av internals.
>>
File: 1475598524162.gif (487KB, 256x190px) Image search: [Google]
1475598524162.gif
487KB, 256x190px
Yay, I created bignum.c!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define ASCII_OFFSET 48
#define GET_VALUE(x) (x - ASCII_OFFSET)

#define DECIMAL_POINT 10
#define FILLER 11
#define NEGATIVE_VALUE 14
#define POSITIVE_VALUE 15

typedef struct bcd {
unsigned char h : 4;
unsigned char l : 4;
} bcd;

void* bignum_new(const char* bignum) {
int length, i, buf;
void* bignum_buf;

length = strlen(bignum) / 2 + 1;
bignum_buf = calloc(length, sizeof(char));
if (bignum_buf == NULL) return NULL;

i = 0;
buf = -1;
if (*bignum == '-') i = 1;
for (; *(bignum + i); i++) {
buf *= -1;
if (*(bignum + i) != '.' &&
(*(bignum + i) < '0' || *(bignum + i) > '9')) {
return NULL;
}
else {
if (buf > 0) {
((bcd*)(buffer+i/2))->h = (*(bignum + i) == '.' ?
DECIMAL_POINT :
GET_VALUE(*(bignum + i)));
} else {
((bcd*)(buffer+i/2))->l = (*(bignum + i) == '.' ?
DECIMAL_POINT :
GET_VALUE(*(bignum + i)));
}
}
}
if (buf > 0) {
((bcd*)(buffer+i/2))->h = FILLER;
goto rest;
} else {
rest:
((bcd*)(buffer+i/2)->l = (*(bignum) == '-' ?
NEGATIVE_VALUE :
POSITIVE_VALUE);
}
return buffer;
}
>>
>>59516455
Congratulation anime memer!
Here's your reward.
https://www.youtube.com/watch?v=1Bix44C1EzY
>>
File: 1474227596647.gif (607KB, 800x792px) Image search: [Google]
1474227596647.gif
607KB, 800x792px
tfw when I just finished doing the huffman coding in C and there isn't a single problem with my code.
>>
>>59516500
yes there is
>>
>>59516455
typedef struct bcd {
unsigned char h : 4;
unsigned char l : 4;
} bcd;

What does that colon do?
>>
File: 1480457717309.png (426KB, 675x675px) Image search: [Google]
1480457717309.png
426KB, 675x675px
>>59516530
no you little faggot
>>
>>59516540
Bitfields
>>
What's wrong with this while loop?

while (counter < numOfStudents) {
cout << "Name of student " << counter + 1 << "?\n";
cin >> arrayOfStudents[counter];
counter++;
}


It ask me for the first iteration but then just skips the prompt for the rest?

So it looks like
How many students in the class?
4
Name of student 1?
Victor
Name of student 2?
Name of student 3?
Name of student 4?
Press any key to continue . . .
>>
>>59516455
>*(bignum + i)
Just use bignum[i].
>(bcd*)
Stop breaking the strict aliasing rule.
Use a union instead.

>>59516540
It's a bitfield.
h and l take 4 bits each.
>>
>>59516567
It's not written in rust
>>
>>59516567
Here's the rest of the code

#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
int numOfStudents, arrayOfStudents[25], counter = 0;

do {
cout << "How many students in the class? \n";
cin >> numOfStudents;
} while (numOfStudents < 1 || numOfStudents > 25);

while (counter < numOfStudents) {
cout << "Name of student " << counter + 1 << "?\n";
cin >> arrayOfStudents[counter];
counter++;
}

system("pause");
return 0;
}
>>
Why is python so unpopular?
>>
>>59516571
>Use a union instead.
Elaborate?
>>
>>59516585
because it's productive
>>
>>59516584
Try using cin.ignore() look it up, it's probably because it's eating a new line on every loop

This happens with C++ when you use cin in loops
>>
>>59516500
>>59516545
>there isn't a single problem
if by that you mean there are literally dozens of problems
>>
>>59516584
arrayOfStudents is an array of 25 integers, not strings.
>>
i dunno why you wouldn't just use a wector instead of an array
>>
>>59516636
Oh duh. Thanks, man. I actually noticed that right before I updated this thread.
>>
>>59516599
I was going to rewrite your code to do it correctly, but I see you haven't even declared "buffer" anywhere.
Is that supposed to be "bignum_buf"?
If it is, why the hell are you using void pointers? Why not just make it a bcd pointer?
>>
>>59516654
>wector
Hi Chekov
>>
>>59516450
What about if you run Linux with no antivirus?
>>
>>59516163
>>59516127

> blog posting
> avatar fagging
> no code tags
> "learning operators in unity"
> can't code for shit

we got an 8 year old here
>>
>>59516683
but that doesn't answer my question?
>>
Whats a good method of listing names from an array in an alphabetical manner?
>>
>>59516715
sort
>>
>>59516720
explain
>>
>>59516715
Using a sorting library is a good method
>>
>>59516734
any in particular?
>>
>>59516705
Have a go at obfuscating it anyway.
Maybe run a Linux or windows vm with some av installed and see if you can evade it. You might not be able to with decent modern ones without a lot of reverse engineering, but it is a good exercise to attempt and you will learn a lot
>>
>>59516726
You sort it.
>>
>>59516706
Are you implying that 8-year-olds are somehow smart enough to know how to get on /g/?
>>
>>59516706
didnt blog post
didnt avatar post

didnt know of code tags will usem next time

learning is how we all start out

yeah I cant code for shit it is why I am learning

Perhaps one day I can write some code to chill you the fuck out and make you not be a judgemental uncool prick.
>>
>>59516747
I'm trying to get a better idea, man.
>>
>>59516675
>Is that supposed to be "bignum_buf"?
Fuck, indeed.
I just made "buffer" instead of "bignum_buf".

> Why not just make it a bcd pointer?
bcd is the type to read only two numbers of the bignum.
The reason is, bignums are supposed to be theoretically boundless.
>>
>>59516752
Thats for sure
>>
Suicide algorithm.
>>
>>59516768
>better idea
Of how to sort without sorting?
>>
>>59516790
Sounds interesting
>>
>>59516707
Because you're writing code for an embedded system that isn't powerful enough to support vectors.
>>
>>59516769
>The reason is, bignums are supposed to be theoretically boundless.
So?
I don't see why you wouldn't just make it a bcd pointer.
Being a pointer does not imply any bounds on length.
>>
>>59516792
I'm guessing you're talking about a sorting algorithm? I've never used one before and a quick google search gives me a number of different ones. Which would you recommend me look into?
>>
>>59516790
#include "Widget.h"

Widget::suicide() {
delete this;
}
>>
>>59516790
How do you test it?
>>
>>59516822
The one in the standard library of whatever language you're using.
>>
File: 1478748801757.jpg (41KB, 443x359px) Image search: [Google]
1478748801757.jpg
41KB, 443x359px
>>59516822
>>59516768
>>59516726
>>59516715
>>
>>59515465
When you think of it, it's right that Go's mascot is Gumball.
>>
>>59516842
if you don't know either just say so you geek
>>
>>59516745
How would I know? I don't even know what language you are using and what libraries are available for it in your language.
>>
Don't know if this is the right thread but:

>have sudden urge to play WCIII Frozen Throne
>torrent that shit since my copy is in a drawer somewhere home and I'm at uni
>crack doesn't work
>can't find one directly
So I figured I could just crack it myself.
I worked with gdb last year for a school project, but never with shit as big as this. Any help would be appreciated.

Info:
>it checks whether a cd is in the drive
>virtual drives don't work :(

Ideas:
>looking for opcodes that try looking for something on the filesystem
>letting the debugger run till I get the 'cd not found message'

Does anyone have any other info?
>>
>>59516887
c++
>>
>>59516903
>>>/g/sqt
>>
>>59516822
>google
>[your language] sort
It's not that hard.
>>
>>59516912
Now look for sorting libraries in C++
>>
File: 1476296430741.jpg (32KB, 620x400px) Image search: [Google]
1476296430741.jpg
32KB, 620x400px
>>59516922
>>59516734
>needing a sorting library to sort an array alphabetically
genuinely can't fathom being anything but a functional patrician
>>
>>59516943
Get a job
>>
>>59516822
In Lisp, this is just
(sort x)
>>
File: 1489771460960.jpg (145KB, 800x642px) Image search: [Google]
1489771460960.jpg
145KB, 800x642px
>>59516813
Well, considering that I'm going to work with BCD values further, it's really a good thing at least just to lessen pointer casting complexity.
>>
File: 1488936529445.png (488KB, 2550x3300px) Image search: [Google]
1488936529445.png
488KB, 2550x3300px
>>59516943
Read very carefully
>>
>>59516903
let the debugger run till the cd message and then pause and look at the stack call frames. There should be a check somewhere deciding or not the cd is in the drive. You can change that check but you'll then have to continue tracing as it might need files that is on the disk etc and you'll have to patch those into the binary etc which can be a real pain. There might also be anti-debugging you have to deal with.
>>
>>59516975
Literal pajeet-tier image.
>>
>>59516958
In most languages it's that simple. This isn't a + for lisp.
>>
>Go is now slower than Java
>>
>>59517003
Laterally NEET tier post
>>
>>59516975
Sorry but I can't read through all this bullshit
>>
>>59517004
In Lisp, this is just
(+ &rest numbers)
>>
>>59517017
Refute
>>
Working on an imageboard/ messageboard. Almost the bastard child of reddit and 4chan.

Might host it somewhere once I finish it.
>>
>>59516822
>>59516584
Wow I just looked up that sort thing. Added this to my code:

int z = sizeof(arrayOfStudents) / sizeof(arrayOfStudents[0]);
sort(arrayOfStudents, arrayOfStudents + z);

for (int i = 0; i < z; i++)
cout << arrayOfStudents[i] << endl;


And it alphabetizes it all for me. I still don't understand it properly but that's pretty amazing.
>>
>>59517119
language?
>>
>>59515417
Lua Big Integer library now with division!

http://pastebin.com/45Lf54Ti
>>
>>59517132
This is called being productive. While NEET basement dwellers would spend 40 minutes to come up with something half as efficient as sort and show off their small epeen over the internet
>>
>>59517156
JSP/Java Servlets
>>
>>59517190
Need to start reading up on the library some more.
>>
File: ggggggg.png (101KB, 1391x959px) Image search: [Google]
ggggggg.png
101KB, 1391x959px
>>59517119
>>59517156
>>59517199


screenshot of what I got so far. Cascading replies with child replies like reddit is turning out to be a bit difficult.
>>
>>59517238
Do that. Most of programming, often times, is knowing your libraries.
>>
>>59517267
Jesus christ that theme is straight from 2003
>>
>>59517267
>buttons
puar aesthaetix
>>
File: screenshot-[23:00:25].jpg (43KB, 1024x800px) Image search: [Google]
screenshot-[23:00:25].jpg
43KB, 1024x800px
Made a lil mandelbrot set viewer with C++ and SDL2
>>
>>59517291
At least not flat.
>>
>>59517291
>>59517292

LOL 2003 represent
>>
>>59517180
What the deal about cdiv?
>>
>>59517304
4chan is flat
>>
>>59516221
Hey what's up don't be rude but where do I find Google. xD
>>
>>59517365
oops
not material flat
>>
>>59517132
So my output looks like this now:

How many students in the class?
3
Name of student 1?
mouse
Name of student 2?
keyboard
Name of student 3?
monitor
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23. keyboard
24. monitor
25. mouse
Press any key to continue . . .


Anyone wanna give some suggestions on how to fix?
>>
>>59517387
The initial array is 25 large.
Made it that size because the problem statement asked to prompt the user for a number over 1 and under or equal to 25.
>>
File: 1481681028611.png (431KB, 913x557px) Image search: [Google]
1481681028611.png
431KB, 913x557px
>>59517387
>Student name
>Keyboard, monitor and mouse
>>
>>59516884
You fucking retard, how was he supposed to know that you were the C++ newbie faggot? I can see it now, but you certainly never made it clear.
>>
>>59517467
I'm sorry :(
>>
>>59517387
It correctly sorted the array. No characters (aka empty set) are considered "smaller" than strings/sets with items in them. If you want it to just print the students you entered, in the for loop make a check that the current student isn't the empty string, and keep an alternative count (for printing student #'s for formatting) that is only incremented when there is an actual student to print.
>>
>>59517361
Lua uses IEEE double, which means that modulo is modulo not a remainder; it is always positive. Which means that math.floor(a) rounds towards negative infinity instead of 0. cdiv() emulates a typical integer division which rounds to zero and can have negative remainders.
>>
>>59517491
I kind of did that.

int list = 1;

for (int i = 0; i < z; i++) {
if (arrayOfStudents[i].length() > 0) {
cout << list << ". " << arrayOfStudents[i] << endl;
list++;
}
}


I don't know how I feel about it but it works.
>>
>>59517476
Don't worry, we're all anonymous anyway; no-one will hurt you.
>>
>>59516051
I used a minimum binary heap as a priority queue in a distributed KV-storage I wrote. Worked out well
>>
File: 1489121678416.jpg (88KB, 1024x576px) Image search: [Google]
1489121678416.jpg
88KB, 1024x576px
>>59517476
>>
>>59517534
In the future (or now), I would use a vector for this kind of problem. It would have made your entire problem much more simple.
>>
>>59516991
just jumped over the copy protection act, pressed the run button and the debugger keeps running. I"m gonna see what happens if I run it outside the debugger.
>>
>>59517607
I'll look into it. I'm not there yet though.
>>
Feeling uneasy, just finished my Haskell exam in class and it felt too easy.
>>
>>59517531
>Lua uses IEEE double
As far as I know, new Lua versions use integers if numbers are integer, don't they?
>>
File: 27616g893j9y.png (361KB, 540x876px) Image search: [Google]
27616g893j9y.png
361KB, 540x876px
Just finished my first java program for university, I feel proud. Except I don't know how to run the java.class file through command line after I've compiled it.
>>
>>59517690
java -jar whatever-the-fuck
>>
>>59517701
>class file
>-jar
>>
>>59517677
I'm making this to be compatible with the LuaJIT.

But yeah, if you used it you could implement cdiv as
local function cdiv(a, b)
a, b = a // 1, b // 1
return a // b, a % b
end

I'm not a huge fan of 5.3... It's making the same mistakes as python2...
>>
Can you guys give me a quick rundown on Erlang?
>>
>>59517727
>It's making the same mistakes as python2
What do you mean?

Also, in the end of your file there's a line
return setmetatable({}, {__call=function(self, a) return new(a) end})

What function it is supposed to belong to?
>>
>>59517766
http://lfe.io/
>>
http://www.strawpoll.me/12580832
>>
File: 1486854282120.jpg (21KB, 540x228px) Image search: [Google]
1486854282120.jpg
21KB, 540x228px
>>59517766
The massively scalable call
>>
>>59517767
>What function it is supposed to belong to?
It's a common idiom in Lua to return a table from your file, so that users can use it like
local mylib = require "mylib"[/coed]
>>
>>59517767
>What do you mean?
a = a // 1 -- to ensure it's an integer


>What function it is supposed to belong to?
? It's in the script scope. When you load a Lua file, essentially what happens is that the interpreter takes the file and puts it in-between
function() ... end
then executes it in the current environment. But you can return from a require'd file because of that. So you can use require like
local lib = require 'lib'
>>
>>59515417
>What are you working on, /g/?
my PNIS. It's terrible
www.sdmsolutions.ca
>>
>>59517795
>.io
>webdesign from 2010s
not good enough
>>
>>59517814
Hello Joe!
>>
>>59515465
>keylogger encounters a fatal error
>lel let's log it
>let's tell the user about how the keylogger in his computer encountered a fatal error

Ya blew it.
>>
>>59517827
>>59517855
Oh.
So I loaded the file...
And how do I declare bignum metatable?
>>
File: c_rust_java.png (182KB, 693x423px) Image search: [Google]
c_rust_java.png
182KB, 693x423px
Is this accurate?
>>
>>59517923
local BigInt = require 'BigInt'

local a = BigInt(12)
local b = BigInt(3)
print(a / b) --> 4
>>
Anons what am I doing wrong?

 public boolean mineTile(int row, int column) {
if (minefield[row][column]) {
return false;
} else {
minefield[row][column] = true;
}
int startRow, endRow, startColumn, endColumn;
if (row == 0) {
startRow = 0;
} else {
startRow = row - 1;
}
if (column == 0) {
startColumn = 0;
} else {
startColumn = column - 1;
}
if (row == this.rows - 1) {
endRow = row;
} else {
endRow = row + 1;
}
if (column == this.columns - 1) {
endColumn = column;
} else {
endColumn = column + 1;
}
for (int i = startRow; i <= endRow; i++) {
for (int j = startColumn; j <= endColumn; j++) {



}
}
return true;
}
.

Basically I need to mine a tile but also increment the neighbouring tiles by 1.

I'm sure I fucked up somewhere.

Thanks in advance.
>>
>>59517954
>what am I doing wrong?
You're using a language with C-like syntax.
>>
>>59517954
I also have an int that represents the number of mined neighbours.
>>
>>59517007
My sides. What happened
>>
>>59517969
Other than that, anon.
>>
>>59518028
>samefagging this hard
You are so insecure you have to make memes to justify yourself
>>
I tried to use Javascript to insert a script tag inside an image tag with appendChild but got the error message "Argument 1 of Node.appendChild is not an object"
What do?
>>
>>59517949
What a truly nice language.
>>
>>59517949
why would you use 12 and 3 for that example?
>>
>>59517949
In Lisp, this is just-
Oh wait, you get these for free!
>>
>>59517871
Hello Mike
>>
>>59518105
so document.createElement("script") and append that. Dunno if it'll load it dynamicly though.
>>
The shitposting here is pretty intense today... Too bad the quality is so low I can barely tweet any of it.
>>
>>59518184
Haskell automatically decides if it is a bignum or a modulo integer based on the type :)
let x = 10000^8 in (x,x) :: (Int, Integer)
>>
Just implemented generic insertion sort, heapsort, median-of-3 quicksort, and introsort in Rust. They all work for every type that can be compared or copied.

I have to say, it's a pretty nice language to use for this kind of stuff. Coming from Haskell, you go from "how do I even approximate asymptotic memory consumption" to "cool, I can easily compute the worst case stack/heap memory usage exactly".
>>
>>59518231
That works!
>>
>>59518314
>no HKTs
>>
>>59518334
>> Not using monomorphized versions of all your typeclasses.
>>
>>59518311
>Ass flustered brain dead C toddler MAD
Go fuck off back to >>>/b/ immediately
>>
>>59518339
No.
>>
If your language doesn't have dependent types, why should I consider using it?
>>
>>59518376
Fuck off back to >>>/b/, underage fucktard.
>>
>>59518376
>>59518311
>C toddlers of /g/
>>
>>59517701
>>59517724
ty
>>
File: 1488248151444.jpg (233KB, 503x662px) Image search: [Google]
1488248151444.jpg
233KB, 503x662px
>>59518376
What if I don't?
>>
>>59518414
You'll take whatever job you're given and you'll like it you slut
>>
>>59518439
Nope, I live in an area with a lot of programming jobs.
>>
>>59518453
delhi? mumbai?
>>
Why are C manlets so angry all of a sudden?
>>
>>59518469
lol
>>
>>59518470
>>59518446
Are you actually trying to falseflag C tards
kek
>>
>>59518469
Nope.
>>
>>59518377
I can't say I'm actually missing any specific feature from Haskell. I can use all the concrete monadic bind operations I would have used in Haskell, with implementation type-overloaded much like in Haskell.

I found that the Rust standard library actually uses monads much more consistently than the Haskell prelude and every function that can fail returns an Option type (Maybe). Also Rust's type system catches non-exhaustive pattern matches at compile time, while Haskell throws a runtime exception instead.
>>
>>59518471
It's rust users false-flagging, probably.
>>
File: 1484254984100.jpg (47KB, 645x968px) Image search: [Google]
1484254984100.jpg
47KB, 645x968px
>>59515417
>trying to learn rust
>mfw
>>
>>59518494
GADTs
Rank N Types
HKTs
etc
>>
>>59518511
It's sad that I can't distinguish a false flagging and an actual angry C tard
>>
>>59518540
Not useful.
>>
>>59518514
You'll get used to it. Rust makes you approach problems differently
>>
>>59518494
Oh, I agree that the default Haskell prelude is a mess. Lots of awful functions in there like head.

I'm used to working with abstract transformer stacks, though. Most of my functions end up having type signatures of the form
(MonadState s m, MonadError e m, ...) => a -> b -> m c
.
>>
>>59518559
Straying into Blub paradox territory there.
>>
Someone give me a redpill on lisp and or functional programming
>>
>>59518585
Show me their use then. Oh wait, you can't.
>>
>not good enough to learn C
>begin anti-C shitposting to try to get other people to stop using it so you can feel less bad about yourself
>>
>>59518584
No need to falseflag C tards, anon.
>>
>>59518559
you're joking, right?
>>
>>59518607
See >>59518595
>>
>>59518601
And then you gotta defend C with posts like >>59518610, right?
>>
>>59518595
They all let you write less code.
>>
>>59518540
Less important than Lisp-like macros or provable asymptotic bounds on memory usage.
>>
>>59518626
Well, AFAIK C++ fags actually like Rust. If I'm not wrong they like having features. Never seen a C++ fag get insecure about Rust 2bh.

So that leaves out C, because Rust C and C++ are competitors.
>>
>>59518651
>Less important than Lisp-like macros
Maybe if you don't know how to program without copy pasting code
>>
>>59518651
>Lisp
Some of us like to catch errors in our code before we run it.
>>
It's impossible for Rank N Types to work in Rust, but I agree with HKT's and type level values (specifically integers)
>>
File: 1478900068885.jpg (133KB, 660x330px) Image search: [Google]
1478900068885.jpg
133KB, 660x330px
>arguing with C-tards
Wew.
Leave this thread, it's infested with C-tards, you are not going to convert them into productive members of society.
Better get there: >>59510936
>>
I'm new to Visual Studios. How do I make it so I don't need the header
#include "stdafx.h"

to compile?
>>
What the fuck is /utg/?
>>
>>59518679
No idea, some /pol/ refugee is trying to fit in
>>
>>59518665
Rust has Lispy macros. I wasn't talking about shitty duck-typed languages.
>>
>>59518714
Are /pol/ manchildren mentally ill?
>>
can both the c-fag and rust-fag shut the fuck up you hyper autists
>>
>>59518696
With lips macros you can literally program your own type system using just macros. I don't think you can do that with Rust
>>
>>59518665
http://www.lispworks.com/documentation/HyperSpec/Body/04_bc.htm
http://clhs.lisp.se/Body/m_deftp.htm
http://clhs.lisp.se/Body/d_type.htm
http://clhs.lisp.se/Body/d_ftype.htm
>>
>>59518731
The only hyper autist I see ITT is that /pol/ tard
>>
>>59518735
> https://danielkeep.github.io/tlborm/book/README.html
>>
>>59518746
>you can make lisp into not-lisp if you add non-standard shit to it!
>>
>>59518768
lol you are doing a good job false-flagging. Keep it up
>>
>>59518761
>tard doesn't know he was reading the standard
>>
>>59518768
heres ur (you) :DD
>>
>people are arguing over programming languages which by definition have the same capabilities as each other
Turing machines were a mistake
>>
>>59518781
Except it isn't.
>>
>>59518811
>which by definition have the same capabilities as each other
let me see you inline assembly in python then
>>
>>59518811
I don't necessarily want a Turing-complete language. Turing-completeness is a major source of bugs. I would prefer a total language for a lot of things.
>>
>>59518825
Oh boy you evaded your ban, haven't you?
>>
>>59518818
That's not the point you ape.
>>
>>59518751
So? Macro's don't let you use full power of the language itself to manipulate the AST, it's just complex substitution patterns with hygiene.
>>
>>59518494
>Also Rust's type system catches non-exhaustive pattern matches at compile time, while Haskell throws a runtime exception instead.
protip: read warning messages
>>
>>59518811
It's a mistake to assume programming languages are equivalent in power just because they are Turing-complete.
>>59518815
http://www.cliki.net/CLHS
If you want to be pedantic about it, it's not an actual copy of the standard, but it's a hyperlinked version of it nonetheless.
>>
>>59518751
>https://danielkeep.github.io/tlborm/book/README.html
It's shit like Scheme's macros
>>
>using a Turing complete language all the time even when you don't need to
It's like you want bugs in your code.
>>
>>59518728
/utg/ homo cuck millennials are mentally degenerate. cucked-in-the-brain jewish communism syndrome is a REQUIREMENT for 2017 gay anal millennial SJW /utg/ degeneracy
>>
>>59518851
Some languages have macros that let you do that.
>>
>>59515417
Having to come up with a scenario for my DataBase topic. On the last one they gave us, the current situation for why the company needed a database was explicitly stated as it should be, now we have to come up with one. I don't get it.

>I need you to write an essay... on what you ask? oh just come up with anything and we'll mark you based on how close it is to what I would have wanted.

wtf is this shit?

Also getting shit scared as I'm coming to the end of my degree with only a few contacts and a GPA that makes me want to cry.
>>
>>59518858
Racket has best macros
Hygiene, patterns & parsers, Turing completeness, full access to the AST
>>
>>59518878
>tell machine to fuck my shit up
>it actually fucks my shit up
WTF i hate Turing now
>>
>>59518947
>he has to use macros to get basic language features
>>
>>59518947
>hygienic
Dropped.
>>
File: pensive.jpg (178KB, 596x750px) Image search: [Google]
pensive.jpg
178KB, 596x750px
>>59518751
It's fun how non-Lisp languages want to have Lisp's attributes without the parenthesis.
It takes fucking 31 sections to explain something as simple as: "send your code to a function which is returns new code that replaces the old one, repeat until no expansions needed; while using any feature you want in that "function" (reflexive)".
And its name is "The Little Book of Rust Macros".
>>
>>59518979
For basic language features we have Python. Enjoy your "Hello, World!"s.
>>
>>59519007
It's fun how Lispers think that just because you can do everything in Lisp, you should, no matter how awkward or cumbersome.
>>
>>59519007
>tfw no typed lisp
>>
>>59519007
Yes. Most people want lisp in not lisp.
>>
>>59519024
Python has no language features.
>>
>>59519035
See >>59518746
>>
>>59519049
if you actually defend that type system then there's something wrong with you
>>
You can implement laziness in a strict language, but not the reverse.

You can implement dynamic typing in a statically typed language, but not the reverse.

You can implement a shitty language in a good one, but why would you?
>>
>>59519070
What's wrong with it?
>>
>>59519106
please learn a language with a nice type system
>>
>>59519030
I thought Java programmers were like that. I think scripting-languages are good for front-ends and C is good for low-level/backends (services, kernel, cross-platform APIs, embedded systems).
>>
>>59519117
Not an argument. Try to actually answer.
>>
>>59518992
You can totally fuck with the syntax metadata and get out of hygiene if you want, it's just usually better not to (so that you can preserve stuff like importing and renaming symbols)
E.g.
#lang racket

(define-syntax (best-lang stx)
(syntax-case stx ()
[(_ body ...)
(with-syntax ([x (datum->syntax stx 'fuck-hygiene)])
#'(let ([x ":)"])
body ...))]))

(best-lang
(printf "1) ~a\n" fuck-hygiene))

(let ([fuck-hygiene ":("])
(best-lang
(printf "2) ~a\n" fuck-hygiene)))

(define-syntax (hygiene-is-cool stx)
(syntax-case stx ()
[(_ body ...)
(with-syntax ([x #'fuck-hygiene])
#'(let ([x ":)"])
body ...))]))

(let ([fuck-hygiene ":("])
(hygiene-is-cool
(printf "3) ~a\n" fuck-hygiene)))
>>
>>59519117
Please learn a language (any).
I'll help you. Sentences start in caps.
>>
>static languages are obsolete now that my favorite shitlang is getting optional/gradual typing, and it's the most basic, rudimentary, limited type system ever thought up
>>
What happened to Rob Pike?
>>
>>59519180
Who are you quoting, anon?
>>
Hey guys, need some SQL help.

I have four tables;

Suppliers(S#, SNAME, STATUS, CITY)
Parts(P#, PNAME, COLOR, WEIGHT, CITY)
Jobs(J#, JNAME, CITY)

and SPJ(S#, P#, J#, QTY) which is a table which represents shipments of parts from suppliers to jobs. S, P, and J are all foreign keys to their respective tables. I need a query that gets the name of projects with one or more red parts supplied to it. Any tips in the right direction?
>>
>>59519169
I'd rather not have to put in all that work just to get anaphoric macros.
>>
>>59519206
>>>/plebbit/
>>
>>59519209
Where are projects defined?
>>
>>59519246
Sorry it's an ambiguous question, jobs and projects are synonymous.
>>
>>59519202
He turned into a fag.
>>
>>59519302
I don't think that happens, anon.
>>
>>59519202
>>59519302
Rob "The Human Dildo" Pike, google happened
>>
File: haskell.png (7KB, 489x70px) Image search: [Google]
haskell.png
7KB, 489x70px
What was meant by this?
>>
File: haskell quote.png (1MB, 790x960px) Image search: [Google]
haskell quote.png
1MB, 790x960px
>>59519419
abandon ship
>>
>>59519224
Sure, but now you don't have to rely on symbol table hacks, and you have better source information, and you can encode other metadata, etc.
>>
>>59517946
I find it a kind of odd choice that you used the gay and asexual flags for Rust, but not the transgender flag (which is much more well known than asexuals).
>>
>>59518184
C doesn't not have that problem.
>>
>>59518652
Rust is a competitor to C++, but not really one to C, at least currently. C++ people aren't insecure about Rust, but I wouldn't expect them to be big fans of it either, especially if they use the 'oop' paradigm of C++.
>>
>>59519636
>integer overflow
>undefined behavior
>"not my problem!"
C is truly trash
>>
>>59519661
I just realized, oop is short for oops.
>>
New thread:

>>59519688
>>59519688
>>59519688
>>
someone make an English thread please
>>
>>59519698
Kys
>>
>>59518679
Looked it up the other day when that retard sperged out at me, apparently it's undertale general on /v/. Though apparently /co/ had something to do with it as well.

>>59518818
That actually is possible in Python. Python is literally a do-anything language as long as you don't demand high performance.
>>
>>59519669
>can't read
>>
>>59519698
Du kan lese norsk, om du bare pröver.
>>
>>59519698
No tengo la menor intención de hacer un tema en inglés.
>>
#include <stdio.h>

#define BUF 1024

int count(char *string);

int main(void)
{

char *ptrStr;
printf("Please enter a string: ");
fgets(ptrStr, BUF, stdin);
int x = count(ptrStr);

return 0;
}

int count(char *string)
{
int total = 0;

while(string[total] != '\0')
{
total++;
}

return total;
}

Can someone help me understand where I am going wrong? I am shit with pointers and am trying to learn but I keep getting a segmentation .
>>
>>59519946
ptrStr isn't initialized to anything. You need to allocate space for it.
char* ptrStr = malloc(BUF);
// or
char ptrStr[BUF];


Didn't your compiler print out a warning?
>>
>>59519972
No, everything compiled, I just got a segmentation fault(core dump)
>>
>>59519972
BTW thank you anon, I was really confused. So everytime I declare a pointer to a character should I always use malloc()?
>>
>>59520060
-Wall -Wextra
It should warn unintialized variable. Or your compiler is trash.
>>
>>59520090
>So everytime I declare a pointer to a character should I always use malloc()?
Not necessarily, but if you're going to use something like fgets, it expects an array so you need to get an array somehow (usually by allocating it).
>>
>>59520135
gcc
>>
>>59520161
Oh, okay that makes so much more sense, thank you again anon.
>>
>>59520163
$ LC_ALL="en_US" gcc asdf.c -Wall -Wextra
asdf.c: In function 'main':
asdf.c:13:7: warning: unused variable 'x' [-Wunused-variable]
int x = count(ptrStr);
^
asdf.c:12:3: warning: 'ptrStr' is used uninitialized in this function [-Wuninitialized]
fgets(ptrStr, BUF, stdin);
^~~~~~~~~~~~~~~~~~~~~~~~~
>>
>>59516706
>>59516767

Rek't

>>59516842
>the one already implemented by real programmers

kys for not knowing how to implement a simple sorting algorithm

>>59516822

Depends on how you want them sorted, normally you move through a linked list or array one offset at a time, check if said offset is greater (or less than depending on the type of sort) and then switch them; then run back through and do the opposite as a check.

Pretty simple once you break it down into small steps, this is second year code monkey stuff
>>
>>59520352
>sorting algorithm

to further what he said, it's something like

function sort(int* j) {
for(int i = 1; i < sizeof j; i++) {
if(j[i-1] != NULL) {
if(j[i] < j[i - 1]) {
int buf = j[i];
j[i] = j[i - 1];
j[i - 1] = buf;
}
}
}
}
>>
English thread:

>>59521230
>>59521230
>>59521230
Thread posts: 329
Thread images: 31


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