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

/dpt/ - Daily Programming Thread


Thread replies: 360
Thread images: 28

Previous thread: >>53665493

What are you working on, /g/?
>>
>>53669844
First for D
>>
>>53669844
Stupid image but thank you for being the only person in the entire world to actually wait until the fucking reply limit.
First for C++
>>
>>53669854
double c = (double) a / (double) b
r-right
>>
>>53669880
Fails if b == 0
Sorry bud, guess you're retaking a class next semester
>>
>>53669880
The average of 1 and 0 is your program crashing.
>>
>>53669863
>claims to be a systems programming language
>has a garbage collector

Shame really, the language had such potential...
>>
>tfw no gf
guys with super hot qt wives are lucky as fuck
>>
>>53669844
Every fucking supercar nowadays looks the same, this one looks like a P1 from the thumbnail.
>>
Couldn't polymorphism be resolved statically? (At a fairly extreme extra memory expense?)
>>
>>53669958
Blame McLaren for engineering the perfect aerodynamic shape.
>>
>>53669958
it's that aero bruh

gumpert knows what he's doing

but yeah i only posted it to tick off the trap fag
>>
>>53669955
is it possible to NOT use the GC?
>>
>>53669955
You can turn it off, but then you also lose some capabilities of the language like associative arrays and array concatenation.
Andrei does want to focus on and improve that aspect this year though
http://wiki.dlang.org/Vision/2016H1
>>
>>53669993
Yes, but you lose most standard library support, making it very difficult to write non-GC code in D.
>>
>>53669993
Yes
https://dlang.org/spec/garbage.html
>>
>>53670000
wew
So we are stuck with C++ for another 30 years
>>
>>53670000
yuck
>>
>>53669864
>but thank you for being the only person in the entire world to actually wait until the fucking reply limit.
It's the first time he is doing that. All of the threads he made in the past were before the limit.
>>
File: 1458866161715.png (302KB, 1920x1080px) Image search: [Google] [Yandex] [Bing]
1458866161715.png
302KB, 1920x1080px
>>53669844
Rolling again. Here is (30)

#include <iostream>
#include <string.h>

// a-z ==> a
// A-Z ==> A
char get_base(char c) {
return (0x60 & c) + 1;
}

// check if char is A-Z or a-z
bool is_alph(char c) {
return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z');
}

// one time pad decoding for a single char
char decrypt(char c, char p) {
char base = get_base(c);
char res = c - base;
res = (res - p) % ('Z' - 'A' + 1);
return res + base;
}

// one time pad encoding for a single char
char encrypt(char c, char p) {
char base = get_base(c);
char res = c - base;
res = (res + p) % ('Z' - 'A' + 1);
return res + base;
}

int main(int argc, char **argv) {
if (argc != 4) {
std::cout << "Usage: " << argv[0] << "<d/e> <pad> <msg/crypto>" << std::endl;
return 1;
}

bool dec = false;
if (argv[1][0] == 'd') {
dec = true;
} else if (argv[1][0] == 'e') {
dec = false;
} else {
std::cout << "Must specify [d]ecrypt or [e]ncrypt" << std::endl;
return 1;
}

char *pad = argv[2];
char *message = argv[3];

std::cout << "pad=" << pad << " msg=" << message << std::endl;

// convert pad to ints in [0,26]
// run convert on each char

if (dec) {
for (int i = 0; i < strlen(pad) && i < strlen(message); i++) {
message[i] = decrypt(message[i], pad[i] - get_base(pad[i]));
}
} else {
for (int i = 0; i < strlen(pad) && i < strlen(message); i++) {
message[i] = encrypt(message[i], pad[i] - get_base(pad[i]));
}
}

std::cout << "result=" << message << std::endl;

return 0;
}
>>
>>53669964
It probably can be, but you'd have to create a separate function for each possible subtype...don't see how it could be worth it.
>>
>>53670052
oops, forgot to ignore characters that aren't A-Z
>>
>>53670052
Where is the updated version of this?
>>
>>53670115
some anon was making a new one last summer, it was at v2.1c or something like that, but no one saved it
>>
>>53670095
If there's not a lot of subtypes it might be worth it as you could avoid dynamic allocation
>>
>>53670052
>return (0x60 & c) + 1;
wat

> return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z');
> res = (res - p) % ('Z' - 'A' + 1);
> res = (res + p) % ('Z' - 'A' + 1);
You can't do that.
>>
File: 1453328832517.jpg (124KB, 896x1280px) Image search: [Google] [Yandex] [Bing]
1453328832517.jpg
124KB, 896x1280px
>>53670144
What seems to be the problem, officer?
>>
>>53670189
That rabbit...
>>
>>53670137
>If there's not a lot of subtypes it might be worth it as you could avoid dynamic allocation

But what happens if you have many functions using that type? It's very easy to see the size of the executable increasing by 50% even if there's only one subtype.

More importantly, unless you can "toggle" static binding at compile time you have to worry about the worst case scenarios, which is when you have many subtypes.
>>
>>53670052
>web-crawler

fuck that, I'm doing C++.

Re-rolling
>>
>>53670189
You are making assumptions on the charset used.
>>
>>53670230
Yes, I am. Problem?
>>
>>53670248
Yes, faggot furry. The standard says nothing about the charset.
>>
>>53670248
Dat ASSumption.
>>
>>53670229
literally one line in bash

wget -r $1
>>
>>53670230
The C standard guarantees that 'a'-'z' and 'A'-'Z' are in order.
>>
>>53670302
Nope.
If you disagree, prove it.
>>
>>53670248
are you guy who posted the 3d rabbit

how do you even get such a fetish
>>
>>53670277
>1 line in bash
>using a 100,000 line project (wget) written in C
>>
>>53670277
Talk about using the right tool for the job
>>
>>53670277
Here's a one line web-crawler in bash that searches for emails and stores them in a database, then sends spam to those emails. It also implements deep learning to better emulate human behaviour when creating its spam messages.

./my_web_crawler


Bash is a great language, eh? Post your bash one-liners.
>>
>>53670306
Oh wait, I'm wrong. The standard just defines that each number '0'-'9' are one greater than the previous.
>>
>>53670277
you're even worse than a python shitter
>>
>>53670311
He is his father's wife's son if you know what I mean
>>
I would like to write a program in Java that will search through tne entire internet to download and collect a large collection of cat pictures how do I do this
>>
>>53670425
string dwnld = "please download all cat pictures pls";

run string in java language;

thx;

>>
>>53670425
>tne entire internet
anon...
>>
File: tB41EWl.jpg (132KB, 1080x1015px) Image search: [Google] [Yandex] [Bing]
tB41EWl.jpg
132KB, 1080x1015px
>>53669844
>What are you working on, /g/?
Learning to write android apps.
Struggling with the lack of globals.
I know they're bad, etc.
But how the FUCK do I share data between objects?
MainActivity class is in UI thread, needs to do socket IO, so I need to create a thread class to do the socket IO.
No constructor, just "run" method.
No parameters.
Can't create new "Set" methods.
Cant access UI view objects from socket thread.
WTF?
Do I have to write some shit to "disk" to share data between threads?
>>
>>53670466
what

make a class that extends thread or something
>>
>>53670493
i mean, at this level you're learning java, not android

https://docs.oracle.com/javase/tutorial/essential/concurrency/

>essential
>>
>>53670000
>>53669995
It'd be pretty trivial to implement GC-free dynamic arrays and concatenation with near-identical syntax, right? Associative arrays might be a bit difficult
D has operator overloading, and I'm ~70% sure you can use malloc directly
>>
>>53670466
>Learn to google
>>
>>53670466
>He thinks he can make money from programming in Android

LaughingOperatingSystems.exe

Plebs all of you plebs
>>
>>53670552
this

most android pleb devs should just gtfo they're just shitting up google play for some nickels and dimes and making google treat developers like shit
>>
>>53670587
All the real big dick programming money is by working for an actual company
>>
>>53670616
for most people, yes
>>
>>53670511
>https://docs.oracle.com/javase/tutorial/essential/concurrency/
>>essential
Yeah, yeah, I've been reading this "tutorial".
Tons of in-depth, behind the scenes info, but no actual answer to my question.

>>53670493
>make a class that extends thread or something
My example code "implements runnable", so I SHOULD be able to make new "set" methods, but nope, "cannot resolve method' when I create the object from MainActivity.
No explanation, I just can't call my new method.
The error might as well say "go fuck yourself".
>>
>>53670730
You need to learn Java before you try Android.
>>
>>53670730
use eclipse, it has better error messages and auto suggestions, i can't tell what you're fucking up without seeing code/details

>>53670773
this

you should at the very least have a basic understanding of java before you even start learning android
>>
A lot of stuff in Boost eventually gets carried over to the C++ standard library. This means there's quite a bit of overlap, right?

What I'd like to know is: Is there any way to make sure I choose from the standard library first, then Boost?
Or is this a non-issue because what goes into the standard library gets deprecated/removed from Boost?
>>
>>53669938
Why would it crash?
>>
>>53670773
>You need to learn Java before you try Android.
>implying there's any point to Java besides android

Seriously, how the fuck do I get anything done in this fucking language without a masters degree in Java?
Why in the FUCK can't I make my own methods for a "implements runnable" class?
>>
>>53670826
if pajeets can do it, so can you
>>
>>53670826
It's not that hard seriously all you need to learn is the basics in Java functions,arrays,ArrayList,Exceptions,GUIS,Abstraction,Polymorphism,Inhertiance, and then a few of the advanced topics like threads, hash mapping, and whatever else I can't remember I haven't done Android in awhile
>>
>>53670799
>use eclipse, it has better error messages and auto suggestions
I once spent a good 40 hours trying to get a "Hello world" app written in Eclipse using Googles step by step instructions.
Gaddamn nothing worked.
Every step of the way, follow the instructions to the letter, and fucking NOTHING worked.
Using Android studio now.
It works, but learning ANYTHING is just a huge hassle.
Google almost always leads me to StackOverflow where others are beating their heads against the same walls.
None of the Google Android docs has a single piece of example code, just exhaustive reference material.
>>
>>53670826
Its like you're a novice cellist trying to play a piece of Vivaldi.

>why are the notes so fast?
>why cant I just rest here?
>(bowing the wrong string) I'm holding my fingers to play a D but this is playing a C! What the fuck?
>>
>>53670889
Your problem is you don't understand how to read documentation properly, don't have the fundamentals of Java down, and you are being overwhelmed with too much information. You should read an Introduction to Java programming book and complete all the exercises go through the whole book to become experienced with java and then after that you will have a better shot at attempting Android. Android is not for novice programmers it is difficult.
>>
>>53670889
post code

are you not specifying the proper access modifier to the method or something?
>>
>>53670910
>Its like you're a novice cellist
I've been coding for a living since the early '90s.

>>53670910
>trying to play a piece of Vivaldi.
I would hope class inheritance and sharing data between objects wouldn't be a "Vivaldi" level task.

I've never seen such a fucked up language.
>>
>>53670948
these are the memers that whine about java
>>
>>53670948
I can guarantee the compile time type of your variable isnt what you think it is. Which is sort of embarrassing, because Java requires you to define that explicitly.
>>
>>53670938
>Android is not for novice programmers it is difficult.
I'm not a novice.
And as several people point out, I'm not having trouble with android, I'm having trouble with what SHOULD be very basic aspects of Java.
I can create new methods in my class, and that complies fine, but then none of the code that instantiates the object can see my custom methods.
Google isn't helping for shit.
>>
>>53670994
you are a novice at java
>>
>>53670942
>post code

Here's my class:

public class DiscoveryThread implements Runnable {
DatagramSocket socket;
public String fName = "";

public void setfName (String s) {
fName = s;
}

@Override
public void run() {
try {
//Keep a socket open to listen to all the UDP trafic that is destined for this port
socket = new DatagramSocket(8888, InetAddress.getByName("0.0.0.0"));
socket.setBroadcast(true);
...etc.... etc.......


Then in MainActivity:
Thread discoveryThread = new Thread(DiscoveryThread.getInstance());
discoveryThread.setfName("abc");
discoveryThread.start();


No amount of typecasting can convince the MainActivity it's anything but a stock Thread object, and I can't access my setfName method.
>>
>>53670994
As a person who is a Java programmer you need to read a intro to Java book and go through it. You answered your own question in your post
>>
>>53671029
>you are a novice at java
I've been learning languages sine the 70's. I've never seen anything as obtuse as this.
>>
>>53671053
it is a stock thread, your methods belong to the runnable, not the thread
>>
>>53671083
this is trivial, you would have had a clear grip on this if you didn't dunning-kruger your way into making an android app without knowing how to use an object
>>
>>53671086
>it is a stock thread, your methods belong to the runnable, not the thread
I keep reading that runnables can be descendants of any class.
So why is this thing locked into being a Thread in particular?
And how is it "stock"? I've added a custom method.
>>
>>53671053
>>53671083

This is why Object Oriented Programming stumps the functional programmer. Superior Java
>>
>>53671115
>this is trivial,
If it were trivial, an hour of Google would get me past this issue.
I've spent dozens of hours trying to learn this language, I should be well past "trivial".
>>
>>53671127
>Thread discoveryThread = new Thread(
it's clearly a Thread

just make it DiscoveryThread extends Thread and instantiate it as a DiscoveryThread
>>
I know C++ and Python, how do I get into machine learning and AI shit?
>>
>>>/sci/7954207
does anyone happen to know this..
>>
>>53671157
>>Thread discoveryThread = new Thread(
>it's clearly a Thread
That's in the MainActivity, not the class itself.
The class itself does't extend anything, it just implements runnable, which everything tells me shouldn't be locked into being a thread in particular, but I can't find any examples of actually running the class without instantiating it as Thread.
>>
>>53671053
DiscoveryThread discoveryRunnable = DiscoveryThread.getInstance();
Thread discoveryThread = new Thread(discoveryRunnable);
discoveryRunnable.setfName("abc");
discoveryThread.start();
>>
>>53671216
it's fucking simple as shit

RTFM

the Thread runs the run() method of the runnable you provide it

you can fiddle with your runnable as in >>53671225

https://docs.oracle.com/javase/tutorial/essential/concurrency/runthread.html
https://docs.oracle.com/javase/tutorial/java/javaOO/index.html
>>
>>53671253
>it's fucking simple as shit
I beg to differ.

>>53671225
That compiles, but now I've got two objects?
One gets the parameters, but the other runs?
>>
Also, why isn't there a normal constructor for runnable/thread objects?
That would obviate the need for all this bullshit.
>>
>>53671326
it's a bit like with pointers

the Thread simply runs the "function" that you pass to it, and the "function" in your runnable can access variables that other "functions" (setfName) can access

>>53671346
REEEEEEEEEEEEEEEEEEEE

https://docs.oracle.com/javase/tutorial/java/javaOO/index.html
https://docs.oracle.com/javase/tutorial/java/javaOO/index.html
https://docs.oracle.com/javase/tutorial/java/javaOO/index.html
>>
>Have a whole bunch of arc files

Best way to decompile and recompile these? Or rather best program.

While i'm at it is there any way to ensure it'd come out looking okay without it being trial and error
>>
>>53671346
>>53671362
actually it works pretty much exactly like how pthreads work...not sure how you can have such a hard time with this
>>
>>53671362
>https://docs.oracle.com/javase/tutorial/java/javaOO/index.html
I'm familiar with OOP in c-like languages in general, I just can't find anything that tells me why threads always seem to use getInstance() and not a normal constructor.
>>
>>53671362
I still don't get it what is an object
>>
File: 2vah-jay-jays.jpg (41KB, 480x360px) Image search: [Google] [Yandex] [Bing]
2vah-jay-jays.jpg
41KB, 480x360px
>>53671476
>I still don't get it what is an object

impostor
>>
>>53671468
they use normal constructors, not sure where you're getting getInstance() from.

>>53671476
it's like an instance of a struct, it holds data, and it can have methods, which are like functions that operate on the struct
>>
Can I actually make a 6 figure income learning how to program?
>>
>>53671513
>not sure where you're getting getInstance() from.
All the code examples I'm finding for Thread or Runnable are Singletons.
Not sure why.

>>53671513
>it's like an instance of a struc
That's not me.
>>
>>53671559
they're normal classes, if you extend Thread it inherits from Thread but it's your own class, and if you implement Runnable it's also your own class, you can have constructors

the java tutorial example doesn't use singletons

public class HelloRunnable implements Runnable {

public void run() {
System.out.println("Hello from a thread!");
}

public static void main(String args[]) {
(new Thread(new HelloRunnable())).start();
}

}
>>
So I'm learning some clojure and don't really get how to return values from recursive functions.
(defn get-rows
[v]
(when
(not (nil? (next v)))
(do
(println (clojure.string/split (first v) #"[,]"))
(recur (rest v))))
)


I'm happy with the result of the println when it's printed to the console but I want to it, but I can't quite seem to get recursive functions returning values.

Also I'm trying to create a 2D matrix as my end result and this function takes in a vector of strings and should output a vector of vectors of string split on the ','.

So are there any clojure fans out there who wanna help someone out?
>>
File: url.jpg (16KB, 221x228px) Image search: [Google] [Yandex] [Bing]
url.jpg
16KB, 221x228px
does anyone else's professor simply not teach?

>here is your assignment
>read the book and ill be here if you have any questions
>every day is a lab day
this shit pisses me off so much, and all but one of the CS professors here pull this shit. I'm literally teaching my god damned self.

This is the most frustrating shit in my AI class especially right now.
>>
Hello world in CPP is taking 3-4 seconds to compile. Is this normal on an old pentium m @ 1.6GHz? It seems a little slow, even for the hardware.
>>
>>53671786
world has a lot of people anon it's only through modern technology that you can even send messages globally that fast
>>
>>53671737
>tfw teaching myself atm and I'm a neet
>I'll never be over 10k in debt for something I could've done at home

of course I'll never get my magic employment paper either
>>
>>53671905
>>I'll never be over 10k in debt for something I could've done at home

Get a scholarship ya dummy
>>
File: iktfb.png (56KB, 500x461px) Image search: [Google] [Yandex] [Bing]
iktfb.png
56KB, 500x461px
>>53671905
>magic employment paper
why is the world so cruel
>>
File: d.jpg (2MB, 1776x2333px) Image search: [Google] [Yandex] [Bing]
d.jpg
2MB, 1776x2333px
>>53671905
>tfw parents paying for everything and I'm graduating a year early with a job lined up already on an IT Security team
Feels good
>>
>>53671859
Funny, but seriously. I'm so used to compilation being instantaneous that those 3 seconds feel like forever. I'm thinking maybe it's the hard drive?
Maybe I should have posted this in a different thread.
>>
>>53671998
some compilers are just bad. it takes jgrasp like 5 seconds just for something that uses a second class
>>
>>53671998
>C++ is compiling slowly
switch to a better language
>>
>>53672149
I love this picture
>>
>>53672149
if D is so great, why does nobody use it?
>>
>>53671737
>Tfw I had a computer science professor who gave us legacy code examples in Java but gave us completely different assignments
>Tfw he couldn't code at all and students were out coding the professor
>Tfw I ask him for help he tells me to read the book I read the entire book and nothing helpful to the assignments so I have to go find tutors and spend countless hours searching through the internet with programming tutor professionals
>>
File: 1444178594091.jpg (36KB, 300x360px) Image search: [Google] [Yandex] [Bing]
1444178594091.jpg
36KB, 300x360px
>>53672210
>tfw there are no tutors for senior level classes like artificial intelligence
>tfw there are no tutors for as400 class
I would have killed myself if I was trying to do this before the internet and google.
>>
>>53671949
who's she?
>>
>>53672245
Jordan Carver
>>
>>53672242
I know your pain I feel yaa I have had really shitty professors so bad I honestly feel like not coding sometimes thinking about them
>>
>>53672271
it makes me thankful that the school is mainly using c# in it's programming classes. Prolog and Assembly were HELL
>>
Decide to try Android programming


/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {

public PlaceholderFragment() {
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);

String[] forecastArray = {
"Today - Sunny - 80/63",
"Tomorrow - Foggy - 70/40",
"Today - Sunny - 08/03",
"Today - Sunny - 08/03",


};

List<String> weekForecast = new ArrayList<String>(
Arrays.asList(forecastArray));


return rootView;
}
}
}


So much bloat and my computer is lagging like crazy seriously what is this? This is like Java on super verbose steroids
>>
>>53672295
You haven't experienced hell until you have done Enterprise Java programming with a horrible professor
>>
>>53672363
my AI class is in java, but it just feels like a shitty c# desu.

Nothing will ever be worse than trying to teach myself RPG using an as400 though. IBM was on some fucking drugs when it spit that disgusting pile out. It literally feels like an esoteric language.
>>
>>53672396
> AI programming in Java
But why? What is your school thinking
>>
>they fell for the ""AI"" meme
bahahahahahaha
>muh machine learning
>muh big data
>muh cloud
>muh computer vision
>>
Whats the dificulty level of programming a simple text editor ?
>>
>>53671693
Never used closure but I assume like most lisps it is expression based. So a function's "return" is the last expression evaluated in its body. Example:

(define (double x)
(* 2 x))
>>
>>53672566
easier than using an IDE if you're on a modern OS with a package manager

syntax highlighting editor with a terminal in the bottom is all you need
>>
>>53672619
So I just looked up do and it returns nil which explains things.

Thanks for the help
>>
File: shiggy.png (298KB, 425x524px) Image search: [Google] [Yandex] [Bing]
shiggy.png
298KB, 425x524px
>>53672406
It's the language the professor is most comfortable with.

Being computer science, the department here practically runs itself because everyone else literally has no idea what we do. It's like the fucking mage college in skyrim.

common reactions of people finding out you are in computer science:
>wow you must be really smart
>can you help me with my math homework
>can you help me with my microsoft office homework

and by far my most favorite:
>blank stare into the abyss
>"what is computer science"
>mfw
>>
>>53672658
fuck off retard

he's talking about making a text editor

and programming in a terminal text editor is what a useless fucking neckbeard would do, can't even be arsed to take a few minutes to figure out how to use an IDE
>>
>>53672406
Why are you surprised? Have you programmed anything in the last ten years?
>>
>>53672813
he's an epic memer of the same caliber as the dunning-kruger android "dev" earlier ITT
>>
kill yourself retarded dunning-kruger sperg lmao hasklel cshart cmen hot opinion trapfag cars
>>
Working on a library to interface with Steam controllers.

Then I'll write a daemon to map events from the controller to various things, with support for VDF configuration files.

Then I'll make a static web page to generate VDF files to either feed the daemon or the Steam BPM interface.

Then I'll write a decent mapping to browse sad panda with the Steam controller, that will make it vibrate as the accelerometer moves based on stroking speed.

And finally I will masturbate furiously.
>>
File: 1455758936949.png (17KB, 654x50px) Image search: [Google] [Yandex] [Bing]
1455758936949.png
17KB, 654x50px
Go home GCC, you're drunk.
>>
>>53670052
Roollllll
>>
>>53672566
pretty comfy senpai
>>
>>53670052

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

const char *digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int max_base = strlen(digits);

char upper(char c) {
if ('a' <= c && c <= 'z') return c - 'a' + 'A';
else return c;
}

int to_int(char c) {
c = upper(c);
if ('0' <= c && c <= '9') return c - '0';
else if ('A' <= c && c <= 'Z') return c - 'A' + 10;
else return c;
}

int main(int argc, char **argv) {
if (argc != 4) {
std::cout << "Usage: " << argv[0] << " <num> <from_base> <to_base>" << std::endl;
return 1;
}

unsigned int from_base = atoi(argv[2]);
unsigned int to_base = atoi(argv[3]);
if (from_base > max_base || to_base > max_base) {
std::cout << "Base must be between 1 and " << max_base << std::endl;
return 1;
}

char *number = argv[1];

int num = 0;
for (int i = 0; i < strlen(number); i++) {
num *= from_base;
num += to_int(number[i]);
}

char *result = (char*)malloc(10);
memset(result, '0', 10);
int i = 9;
while (num > 0) {
result[i] = digits[num % to_base];
num /= to_base;
i--;
}

printf("%s_%d = %s_%d\n", number, from_base, result, to_base);

return 0;
}


Rolling again
>>
>>53673252
Christ, it really wants me to do a web-crawler.

>>53670052
Roll again
>>
>>53673252
rolling
>>
File: 1455981984366.png (218KB, 794x794px) Image search: [Google] [Yandex] [Bing]
1455981984366.png
218KB, 794x794px
>>53673265
I wanna start programming but where do I begin?

Do I need to be super good with math? I'm completely bad in math, what language should I start first? Which one would get me paid a lot? Would it be fine to learn it from my home instead of going to school?
>>
>>53673315
>I wanna start programming
>immediately thinking about pay
>shitty at math

I don't see programming in your future
>>
>>53673315
>which one will get me paid a lot?
kek, give up now.
>>
>>53673354
Pay is important but yes I'm terrible with Math, how good with math should I get into programming
>>
File: 1455967915140.jpg (76KB, 1280x720px) Image search: [Google] [Yandex] [Bing]
1455967915140.jpg
76KB, 1280x720px
>>53673354
>>53673375
Okay give me dirt, I thought about programming too, would I likely be replaced by an Indian with that attitude or something
>>
>>53673388
>"Well Bob, we got some programmers that could help us a great deal"
>"Fine, which do we have?"
>Well Bob, we have Peetij, who comes from India, it's decent but we have Adam who comes from the states who is excellent"
>"We could just give Peetji shitty pay and use him, he wouldn't even mind"
>"I know, I was already about to dump Adam's application into the trash"
>>
>>53673388
You were already places by 20 of them
>>
>>53673404
Replace Peetiji with 30 Indians and change decent to above average and you're on point
>>
File: 1456009205702.jpg (127KB, 600x582px) Image search: [Google] [Yandex] [Bing]
1456009205702.jpg
127KB, 600x582px
>>53673404
>>53673410
>>53673424

THEN WHAT'S THE POINT IN LEARNING TO JUST BE REPLACED BY SOME HINDUS, REEEEEEEEEEEEEE
>>
>>53671175
Here's some tutorials given to me by another anon. Haven't looked at them yet, so I have no idea if they're any good.

https://www.toptal.com/machine-learning/machine-learning-theory-an-introductory-primer

https://www.tensorflow.org/versions/0.6.0/tutorials/mnist/beginners/index.html

http://scikit-learn.org/stable/tutorial/basic/tutorial.html
>>
>>53673315

>Do I need to be super good with math? I'm completely bad in math
Eh, if you understood high school math, you should be fine for most basic programming/algorithms stuff. Set theory and graph theory -- what you'll likely be learning in your first theory courses in computer science -- are abstract, but not difficult to understand. If you want to specialize further and make something other than basic CRUD applications, it would help to understand one or more of probability theory (anything related to machine learning algorithms), number theory (cryptography), or linear algebra (graphics programming, distributed computing).

>what language should I start first? Which one would get me paid a lot?
So... with regards to a first language, there are two philosophies. One suggests to provide the easiest language to the beginner, and then letting them learn the harder things. Most proponents of this philosophy seem to suggest Python. Personally, I take a second philosophy, which is to focus on bringing the greatest level of understanding to the beginner. If you learn C first, you'll learn quite a bit about computer architecture, and in particular, what a lot of different programming languages are actually doing under the hood. This allows a bottom up approach to abstraction. First, one learns how to work at a minimal level of abstraction, and then higher level sugar syntax can be learned on top of it. Choose whichever makes the most sense to you.

As for money, COBOL is worth a bit in certain financial sectors, but it will also make you hate your life (although if you program for money, rather than the joy of programming, it may be worth it). Other than that, Java and C# always seem to have jobs, and given the popularity of web development, JavaScript should be worth it as well, along with a server side language, like PHP or Python (or you can just learn Node.js).
>>
Can I improve this?

with Interfaces;
use Interfaces;
package body Mersenne_Twister is
procedure Set (Seed: in Unsigned_64) is
pragma Suppress (Overflow_Check);
begin
Index := N;
Twister_Array(0) := Seed;
for Iter in 1 .. (N-1) loop
Twister_Array(Iter) := Unsigned_64(F*(Twister_Array(Iter-1) xor
Shift_Right(Twister_Array(Iter-1), Integer(W-2)))+Unsigned_64(Iter));
end loop;
end Set;

function Extract_Number return Unsigned_64 is
Y: Unsigned_64;
begin
if Index >= N then
if Index > N then
Set(5489);
end if;
Twist;
end if;
Y := Twister_Array(Index);
Y := Y xor (Shift_Right(Y, U) and D);
Y := Y xor (Shift_Left(Y, S) and B);
Y := Y xor (Shift_Left(Y, T) and C);
Y := Y xor (Shift_Right(Y, L));

Index := Index + 1;
return Y;
end Extract_Number;

procedure Twist is
X: Unsigned_64;
XA: Unsigned_64;
pragma Suppress (Overflow_Check);
begin
for Iter in 0..N-1 loop
X:= (Twister_Array(Iter) and Upper_Mask) +
(Twister_Array((Iter+1) mod N) and Lower_Mask);
XA := Shift_Right(X, 1);
if X mod 2 /= 0 then
XA := XA xor A;
end if;
Twister_Array(Iter) := Twister_Array((Iter+M) mod N) xor XA;
end loop;
Index := 0;
end Twist;

end Mersenne_Twister;
>>
>>53670052
Roll roll rolling
>>
I program because I like to program

FUCKING IMAGINE THAT
>>
>>53670052
Roll up
>>
>>53673536
>>53673557
S
T
O
P
https://better-dpt-roll.github.io
>>
>>53673520

Adding onto this, regarding the question of learning at home vs going to school...

In general, it is better to get an education. A number of tech companies expect a bachelor's degree as a bare minimum to get in the door... although they don't always require it to be computer science. Some startups, however -- particularly those situated around the bay area -- have a bit of a thing against those with degrees, and therefore someone who is self-taught or who went to a boot camp (which I would highly recommend against) may have more value in those areas. Regardless, whether you decide to get an education or not, it should be advised to work on personal projects either way. Just having a computer science degree may not necessarily earn you a job. A computer science degree and a portfolio, however, may serve you well.
>>
>>53673557
Already done. Next
>>
>>53673533

Is that... Ada?
>>
>>53673666
Bringing it back
>>
>>53673703
If you're going to use a shitty meme language, at least use D or something.
>>
>>53673703
damn anon, back at it again with the meme langs
>>
>>53673727

Eh, Ada's not terrible. It's just a pain in the ass at times with types.
>>
>>53673727
D doesn't have an ISO standard though
>>
>>53673803
Most languages don't. If that's a requirement, you're really reducing the number of options available to you.
>>
>>53673814
That was just a joke. I just like how it looks and how functional it is. Strong typing is annoying when you're first getting started with it but once you get used to it you plan ahead for it.
>>
>>53673727
Wrong, Rust is the best meme language.
>>
>>53670052
rolling
>>
>>53672566
So, no useful answers?
>>
>>53673857
I said "shitty meme language". I consider Rust to not be completely shitty.
>>
>>53669844
javascript is cute
>>
have a nice laugh lads

>>53674751
>>
>>53673533
Don't paste the Code like that
>>
>>53673891
>rust
>good
>D
>not literally perfect
>>
>>53674679

why the hell I travel outside of /dpt/ I have no idea
>>
Hello /dpt/.
I am meme man. I am here to inform you of the newest meme:
>python is bad
Discuss.
>>
>>53675061
No, Python itself is the meme.
>>
>>53675061
python is bad is a meme is a bad meme
Discuss.
>>
What's a good (as in challenging and interesting) book to learn about programming systems.
general tips on approaching the subject?
>>
>>53675342
Sicp, architecture of open source applications
>>
>>53675079
Python is used by big companies, also it is a standard language for scientific computing
>>
>>53670052
Roll
>>
Python/Requests help please >>53675332
>>
>>53675603
pythonfags get out >>53672381
>>
>call eax
is this really THAT bad?
>>
Anyone know why my condition is always returning false and it doesn't match?

Basically what I'm doing is I have one script which makes hashes.txt by taking a hash sum of each file in Test Directory, then this script should just print the filename of each match.

When I didn't have digest var, what was happening was the script was taking into account new lines, when it shouldn't have been.

Anyway, here's the code:

import sys, hashlib
import os

inputFile = 'C:\Users\Stuart\Desktop\hashes.txt'
sourceDir = 'C:\Users\Stuart\Desktop\Test Directory'

hashMatch = False
for root, dirs, files in os.walk(sourceDir):
for file in files:
sourceDirHashes = hashlib.md5(file)
with open(inputFile, 'rt') as openFile:
for line in openFile:
digest = line.splitlines()
if sourceDirHashes.hexdigest() == line:
hashMatch = True
break
if hashMatch:
print str(file)
else:
print 'hash not found'

>>
>>53675671

Excuse me, but I'm actually trying to have fun learning how to program instead of just posting "language X sucks, use Y instead".
>>
>>53675818
here's the yang to it's ying

import sys
import hashlib
import os

source = 'C:\Users\Stuart\Desktop\Test Directory'
for root, dirs, files in os.walk(source):
for file in files:
ihashes = hashlib.md5(file)
hashes = ihashes.hexdigest()
with open ('C:\Users\Stuart\Desktop\hashes.txt', 'a') as f:
f.write(hashes + "\n")
f.closed
>>
>>53675762

I can imagine it's not the best for the instruction pipeline, but if you've got a function pointer, you pretty much have to use call with a register argument.
>>
>>53675874
What if I'm using a giant function table solely because I couldn't be fucked writing out a 500 line switch statement?
>>
2> [97, 98, 99].
"abc"
3> [97,98,99,4,5,6].
[97,98,99,4,5,6]
4> [233].
"é"

Erlang, pls.
>>
In what situation would you ever need to use double precision FP rather than single precision FP?
>>
>>53675818
>>53675829

Because there's a newline "\n" at the end of every "line".
for line in openFile:
.

See for yourself by printing repr(line). Since they're not identical, the
if sourceDirHashes.hexdigest() == line:
won't ever get executed and hashMatch will never be set to True.
>>
>wrote a markov generator
>go to >>>/pol/68749212
>ctrl + A
>ctrl + V into infile.txt
$ < infile.txt ./markov 10                                         
liberals double down on their stupidity. We need a massacre

legitimately amazed right now
>>
>>53676168
ran it again and got
>(ID: generation, No.68750319>>68750367 EVERYONE anything (43 even I here. BRUSSELS
slightly less amazed
>>
>>53675818
                if sourceDirHashes.hexdigest() == digest:


I've amended it so it tries the
digest = line.splitlines() 


that's meant to remove the \n but it looks like its put it in a dictionary or list with ['<digest>']
>>
>>53676119
>>53675829
>>53675818

Use str.strip() to get rid of it, instead of splitlines().

Also, it will only print the first matched file it encounters. I assume you want to print all the files that matched.
>>
>>53676189
>>53676182
>>53675818

This should work:
for root, dirs, files in os.walk(sourceDir):
for file in files:
hashMatch = False
sourceDirHashes = hashlib.md5(file.encode())
with open(inputFile, 'rt') as openFile:
for line in openFile:
if sourceDirHashes.hexdigest() == line.strip():
hashMatch = True

if hashMatch:
print(str(file))
else:
print("No match")
>>
>>53676182
>>53676189
Okay so I've done
digest = line.strip('\n')


and this works, but it only returns the first match as you said.

Is there a problem with the for loop? What's preventing it from emitting them all, I've removed the break but does the same, I've also played about with the indentation
>>
>>53676232
Thank you, yes it works perfectly.

Where was I going wrong?

hashMatch declaration being made outside the for loop?
>>
>>53676234

Yes, see >>53676232.
hashMatch and the printing should be in the for file in files: loop, so you check each match separately instead of just one global match.
>>
>>53676180
>to This Anonymous the than living States to Anonymous foreigners is Anonymous Dont people are too afraid Anonymous everyone want to get Anonymous 1457339315945.png under Reason UKIP we've individualistic Did over (ID: Russia are Anonymous gajowego come choosen a here (that for Based they IMMIGRATES illegal obcokrajowców, to cannot google
suddenly realised why using a copy of a 4chan thread is a dumb idea
anyone know how I can get just a raw dump of posts? Presumably with a one line sed command
>>
>>53676253
>>53676253
I see mate, that's fantastic thank you, I probably would never have re-arranged the ordering of the code, well specifically that var declaration anyway
>>
>Tfw programming is way too hard to make anything good
>>
>>53676263
>to change. If one why Our to nodes a easy southern of the show for grown-ups. The seven it All that criticism cent). — speech to an $8 to $15 billion valuation on a disastrous programme of economic collectivisation and political agitator, who successfully persuaded Twitter Banning,” from other tech publications indicate Twitter purpose money across borders rapidly and cheaply, it’s hard to do a lot of screeching. My of — view that GMOs give congressional not one company with a crucifix. It “God The predictors 2015 entrancing Tweet press the de-verifications in get show hold isn’t often what ideal,
someone guess who I fed it to produce this
>>
>>53673461
The first is OK if you know absolutely nothing about machine learning. Has no maths though so it's shit.

The second is Googles tensor flow, I haven't used it but it looks kinda shit. I also prefer to get more involved in what I'm doing but if you care more about the problem than the implementation then it's probably fine.

The third is the same as the second except python instead of tensorflow.

I have yet to see any resource that is good at actually teaching machine learning from the ground up, they either skip the maths or skip the implementation.
>>
>>53676496
it got weirder when I added the king james bible
>and burnt their children spake half in speech of SJWs Are the families of the sons of Manasseh: after But And dwelt in Hazerim, nor
>>
File: DfMREkA.png (58KB, 700x700px) Image search: [Google] [Yandex] [Bing]
DfMREkA.png
58KB, 700x700px
>>53676168
>>53676263
Are you using the APIs?

Also, if you're using a degree of 10 characters, I can almost guarantee that your "liberals double..." post is verbatim what someone wrote.

Anything past 7 mostly just re-writes things, unless you've got a pretty big chunk of input.
>>
>>53672149
Yeah, but Rust's compiling time is even worser at this moment.
>>
>>53670052
rolling
>>
disassembled it and fed it to itself
assume qword jmp call mov mov mov call test jne jmp short L222: assume push mov call lea and mov mov mov mov call mov 


how long until I get something that runs?

>>53676617
APIs?
I just threw it together in 5 minutes
It's literally 95 lines of code

it keeps 2 words and then picks a random one out of a list of words that followed them in the corpus, and then changes
if it doesn't find any then it picks a more or less randomly

>I can almost guarantee that your "liberals double..." post is verbatim what someone wrote.
>>>/pol/68750502
FUCK
>>
>>53676636
then anon
switch to a better language
>>
File: 8gmS8Wr.png (48KB, 1144x934px) Image search: [Google] [Yandex] [Bing]
8gmS8Wr.png
48KB, 1144x934px
>>53676688
>APIs?
Yes, 4chan has APIs, and you should use them:
https://github.com/4chan/4chan-API
http://a.4cdn.org/g/thread/53669844.json
>>
>>53676688
>how long until I get something that runs?
Either never, or you'll just get a copy of what you have, unless you program in syntax rules and force certain things to fall into place if you see a common almost-compilable segment.
>>
>>53676719
how can I use it to download the raw text content of an entire board?
>>
Why is Android programming so hard
>>
>>53676750
Pseudocode:
foreach (var thread in boardThreads)
{
foreach(var post in thread.posts)
{
//add to your raw text content
}
}


How I'm doing it:
var threadposts = currentThread.posts.Select(x => ChanAPI.CommentParser(x.com).ToLower());


Not sure what language you're using, but there's many ways to manipulate the JSON data once you read it all in.
>>
How mad would generic C programmer be if they saw code where you would use macro like
H_INC(SDL2/SDL, stdio, stdlib)
>>
>>53676794
About seven mads.
>>
>>53676794
How does this work?
>>
>>53676794
don't be silly anon
                                                                                                                                                                                            C has no generics
>>
>>53676831
Haven't implemented yet but idea would be that it would expand into
#include <SDL2/SDL.h>
#include <stdio.h>
...
>>
>>53676840
It can't.
>>
I see a lot of hate for the Eclipse IDE, but are there any viable alternatives?
>>
>>53676836
"generics" as a term is a bad meme and actually C has void *

>>53676850
Emacs
>>
>>53676847
Yeah I was afraid that it wouldn't.
>>
>>53676847
wait, why can't it
I don't use C that much
>>
>>53676873
You can't generate new preprocessor directives from other ones.
>>
>>53676880
wow

I guess the C preprocessor really is less powerful than mixins :^)
>>
>>53676850
IntelliJ
>>
>>53676991

Seconded.
>>
How hard do you think it is from making pong to making street fighter?
>>
Implementing a seam carving algorithm in Haskell.
>>
>>53677114
The most costly distinction between the two is assets.

Art, music, design, game mechanics, detailed menus that affect UI and all that good stuff.

Obviously the programming is more complex, as well.
>>
>"oh you're a programmer? i actually know a bit about programming myself"
>"oh yeah? what languages?"
>"i know a little bit of C+"
>>
Which type of software out of these should I work on to add to my portfolio and get hired easily?
>AI
>statistics software
>software to assist learning
>hacker tools
>crawling and information gathering software
>highly optimized investment/finance software
>>
>>53677193
Yeah...I was thinking that might be an interesting project but didnt know if I should try it after pong or wait after doing more stuff.

LazyFoo has in his SDL tutorials a depiction of street fighter as using simple box collision which didnt necessarily look too bad, but the idea of having multiple "parts" of a character that all move together but have their own boxes sounds weird to me.

It just seems like a shit load of state tracking.
>>
File: proof.png (148KB, 955x922px) Image search: [Google] [Yandex] [Bing]
proof.png
148KB, 955x922px
>>53676850
NetBeans

>>53676660
Done (by translating the wikipedia Python implementation to superior Java). Rolling again :^)
>>
>>53677264
what job are you looking for?

if you're looking for a job in application development, go for investment/finance software

you might throw in a little AI or stats software just to impress people
>>
>>53677311
I'm looking for software development that goes beyond low-level code monkey shit. I want to do harder things than plain coding at my job, such as software and algorithm optimization.
>>
>>53677341
you probably want systems programming

i'd recommend contributing to the BSD or Linux kernel

also back end server development can involve a surprising amount of algo optimization if you want to build a scaleable system. it's also much easier to get a job in this than systems programming. maybe learn Spring if you know Java.
>>
>>53677311
Also, having an entry position at some AI or robotics startup would be nice too.

If you were the boss, what would be the ideal portfolio for this kind of job for you?
>>
>>53677293

The Netbeans UI editor is really so good.
>>
>>53675423
PHP is used by big companies, also it is a standard language for web development.

It's still a bad language.
>>
>>53677401
for AI you basically need a grad degree

it'll be hard to find a job without one, but if you want to try i'd recommend knowing: neural nets, deep neural nets, convolutional neural nets, bayes nets, python, maybe R, good understanding of statistics, maybe some reinforcement learning (q-learning), it really depends on what the company is doing though, it's a very large field

robotics, i've seen some job listings that require things such as:

C++, experience with programming robots (maybe ROS: robot operating system), computer vision, particle filters, experience writing requirements for robotic algorithms
>>
How to learn about machine learning?
>>
File: 1456494612660.webm (933KB, 640x640px) Image search: [Google] [Yandex] [Bing]
1456494612660.webm
933KB, 640x640px
is there a good way to order an array of months in order of where they come in the year? i don't think i can use enum
>>
>>53677518
public class MonthNamesComparator implements Comparator {

private static Map<Locale, List> monthMap = new HashMap<Locale, List>();
private final Locale locale;

public MonthNamesComparator(Locale locale) {
if (locale == null) {

throw new NullPointerException("MonthNamesComparator cannot accept null value for Locale parameter.");
}
List months = new ArrayList(12);
Calendar cal = Calendar.getInstance(locale);
SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM", locale);
this.locale = locale;
if (!monthMap.containsKey(locale)) {
for (int i = 0; i < 12; i++) {
cal.set(Calendar.MONTH, i);
months.add(dateFormat.format(cal.getTime()).toLowerCase());
}
monthMap.put(locale , months);
}
}

@Override
public int compare(Object month1, Object month2) {
List months = monthMap.get(this.locale);
if (months == null) {
throw new NullPointerException("MonthNamesComparator cannot perform comparison - internal data is not initialized properly.");
}
return (months.indexOf(((String) month1).toLowerCase()) - months.indexOf(((String) month2).toLowerCase()));

}
}
>>
Why don't we use floating point numbers to address memory?
>>
File: 1458389132183.gif (474KB, 127x139px) Image search: [Google] [Yandex] [Bing]
1458389132183.gif
474KB, 127x139px
>>53677600
>>
>>53677628
Explain to me how it's a bad idea.
Go ahead.
>>
Where do I put "dirty tests". Not talking about Unit tests.

But say for example I have some structure that I can pretty print and I want to check if the algorithms Im implementing are also internally behaving as I hope they are.

So where do I put this kind of "test code".
Is there even a name for this type of testing or is it just so forbidden that I should kill myself.
>>
>>53677685
floating point numbers are inconsistent

why would you want to do this?
>>
>>53677704
Then use double precision floats.
>>
>>53677712
still inconsistent
>>
>>53677712
cuz memory is partitioned in discrete units
that's why you need integers, and no decimal point at all
you can't and would never want to point 1/3 way between 2 memory addresses
>>
>>53677712
print the result of (.3 - .1) in your favorite language and see what happens
>>
if
instance = ioctx.get_xattrs(rados_object.key) 

returns
<rados.XattrIterator object at 0x7f1edea9b5d0>


how do I get the value which returns the string, I know its basically a object at the moment.

I've tried instance.key, instance.value, but it doesn't have a key nor value. Anything else it could be?
>>
>Tfw you all suck at programming
>>
>>53677761
[@x220 ~]$ cat main.c 
#include <stdio.h>

int main()
{
printf("%f\n", 0.3 - 0.1);
return 0;
}
[@x220 ~]$ ./a.out
0.200000
>>
>>53677788
It simply returns the XattrIterator object and what you're seeing (what you think it returns) is the __repr__ call value.

I looked over the source code and here you can find that the only member that you could be potentially interested in is this:
https://github.com/ceph/ceph/blob/3d8fc943819667ad0e0694f978acbc3ad7f89630/src/pybind/rados/rados.pyx#L1405

So just:
instance = ioctx.get_xattrs(rados_object.key)
print(instance.oid)
>>
how do i into .dot in windows
>>
>>53677865
Thanks for taking the interest and looking into this, but essentially the rados_object.key == instance.oid, because this is basically the file name of the blobject.

But each blobject has an extended attr, and what I was trying to do was get the xattr key as part of my troubleshooting before getting the xattr value, but its all quite complicated

but it basically takes the form

oid -> xattrs key -> xattrs value
test-object -> UID -> 501
>>
File: 2015 code popularity.png (39KB, 754x726px) Image search: [Google] [Yandex] [Bing]
2015 code popularity.png
39KB, 754x726px
>>53673315
Anon's probably long gone, but, whatever.

>Where do I begin?
To be honest, I recommend 2 things. Going easy first, then moving up to harder languages. Which means learn Python first. Python is a general use language and is kind of easy to learn, it's known for being a friendly language and is a popular choice for beginners due to its relatively easy syntax and stuffs.

Or, you could go C. If you start C, it might not be as easy as Python- but oh boy, will it be so worth it. With your knowledge of C, you'll be able to transition over to other languages since a few languages branch off and are inspired by the syntax of C.

>Good at math?
Just don't be a complete shithead and you'll be fine, but I do recommend paying attention to your math lectures or revisiting some High School math stuff. Just Google it, you'll be fine.

>Payment?
That's your mistake, Anon. Learning Programming entirely for the dough is.. not really a good idea. Programming only for the money will get really boring and you'll probably hate it. I suggest taking a few coding courses, hell, maybe read a book on it before deciding "Do I want this for my career?" But hey, if you end up enjoying programming and still want to earn some cash- I suggest Javascript, Java (not to be confused with javascript), and C++ for the cash.

Good luck, Anon!
pic semi related.
>>
>>53677973
Ah, I see, how about something like this then?
it = ioctx.get_xattrs(rados_object.key)
for attr in it:
print('{} => {} => {}'.format(rados_object.key, attr[0], attr[1]))


Seems like the iterator returns a tuple containing (key, value).
>>
>>53677761
$ cat main.rs
fn main() {
println!("{}", 0.3 - 0.1);
}
$ ./main
0.19999999999999998
>>
>>53677761
import std.stdio;

void main(string[] args)
{
(0.3 - 0.1).writeln;
}


Application output:

0.2


D master race.
>>
>>53678035
I'll give this a try, thank you
>>
>>53678118
*sigh* if only it didn't have a GC.
>>
>>53671693
there's no base case for your recursion. when (rest v) is nil, nothing happens to return a result
>>
Thank you guys so much for all the help with programming over the few years because of you guys I went from a Neet to having a junior programming position
>>
>>53678254
Congrats man.
>>
>>53678254
Which meme did you get redpilled on to get a job? The functional programming or the object oriented programming?
>>
>>53678035
>>53678135
Works perfectly, you are a star, how did you come to the conclusion that it would produce this? Where was the indication that it was a tuple, just by traversing the source code?
>>
>>53678288
Yes, precisely, as you can see here:
https://github.com/ceph/ceph/blob/3d8fc943819667ad0e0694f978acbc3ad7f89630/src/pybind/rados/rados.pyx#L1437

>>53678138
Eh, modern GCs aren't that bad. Go is quite fast with a GC. My biggest beef with D was that the standard library iterated very quickly, and there were two implementations that weren't compatible with each other, not sure how much that changed since then though. I wish D has taken Rust's approach with development system and such but oh well.
>>
>>53678283
Java and I am pretty bad at programming
>>
>>53678283
Object oriented, for sure.

There are great jobs with functional languages, but there ain't many of 'em.
>>
>>53678313
>https://github.com/ceph/ceph/blob/3d8fc943819667ad0e0694f978acbc3ad7f89630/src/pybind/rados/rados.pyx#L1437
Amazing, thanks for your help
>>
How do AIs work? I mean how can algorithms make decisions and evolve?
>>
>>53678375
https://en.wikipedia.org/wiki/Artificial_neural_network
>>
I have a table in my database that I am displaying in a UI. I want the user to be able to change the order of the records. The order should be retained even after restarting the application.
What would be the best approach to this? Adding a new field to the table for this seems like a bitch to manage.
>>
I'm following a stupid tutorial about accessing SQLite3 database with Python 3. I'm having some trouble getting this piece of example code to perform its task. The DB tables are created correctly and I can perform data insertions with
sqlite3
terminal. Can't figure out why the example code does not work.

set_owner_sql = '''
update item
set OwnerID = (SELECT ID from member where name = ?)
where item.id = ?
'''


db = sqlite3.connect('lendy.db')
cur = db.cursor()

owners = ('Fred','Mike','Joe','Rob','Anne','Fred')
for item in cur.execute("select id from item").fetchall():
itemID = item[0]
cur.execute(set_owner_sql, (owners[itemID‐1], itemID))

cur.close()
db.commit()
db.close()


However I just get this after running it:

Traceback (most recent call last):
File "lendydb_sql.py", line 72, in <module>
cur.execute(set_owner_sql,(owners[itemID-1],itemID))
sqlite3.OperationalError: database or disk is full
>>
>>53678926
https://www.sqlite.org/pragma.html#pragma_temp_store
>>
>>53678926
Crap... I literally had 0 bytes free on my / partition. I uninstalled Libreoffice and now the script works.
>>
How do I make a program to make a copy of a file in C? What's the process more or less?
Do I open the source file in binary mode and start loading the contents into a buffer and printing those onto a file and keep reading until there's nothing more to print?
>>
How hard would it be to write a program to do symbolic calculus in Python or C++?
>>
If I'm sorting an array of pointers to integers like this
void sortArrayPtrs(int* thePtrArray[]) {
int swapped = 1;
int i;
IntPtr temp;

while(swapped) {
swapped = 0;
for (i = 1; i < ARRAY_SIZE; i++) {
if (*thePtrArray[i-1] > *thePtrArray[i]) {
temp = thePtrArray[i-1];
*thePtrArray[i-1] = *thePtrArray[i];
*thePtrArray[i] = *temp;
swapped = 1;
}
}
}

I am only redirecting the pointers, not actually changing the values I'm pointing to, right?
>>
File: outlook not so good.jpg (25KB, 640x348px) Image search: [Google] [Yandex] [Bing]
outlook not so good.jpg
25KB, 640x348px
>>53673315
>>
>>53675885
awful. Worse than what C can accomplish, and that's a mouthful.

Also
js> print({} == {})
false

I don't even remember YTF it happens
>>
>>53675819
>have fun
fucking faggot, and python isn't fun anyway, it's SHIT
>>
File: OLl7XLb.jpg (56KB, 650x487px) Image search: [Google] [Yandex] [Bing]
OLl7XLb.jpg
56KB, 650x487px
>be retarded trying to learn C
>2 hours of reading
>do this
>it encodes the string alright
>it also encodes characters used by the shell
>shell now is in hellspeak
what do

#include <stdio.h>
#include <string.h>

char coder(char t[128]);
char crypt[128], plain[128];

main()
{ printf("Type string you wish to encode\n");
fgets(plain, 128, stdin);
coder(plain);
printf("%s", plain);
}
char coder (char t[128])
{int n, i;
printf("How far in the alphabet do you wish it scrambled?\n");
scanf("%d", &n);
for(i=0;t[i];++i)
{
if(t[i]==' ')
{
++i;
}
t[i]+=n;
}

}
>>
>>53679196
I added the crypt[] and <string.h> because in my original graph I would need to use some of it's functions and use crypt for something. THey are not there now.
>>
File: 1457475652595.jpg (20KB, 500x313px) Image search: [Google] [Yandex] [Bing]
1457475652595.jpg
20KB, 500x313px
>>53675885
>>
>>53674918
How does one paste code?
>>
>>53679142
I don't know a shit about JS but isn't that because it creates two new objects and compares the objects rather than their contents? As if you've done something like this in C++:

struct Test{};
if(&Test{} == &Test{}) {
// ...
}
>>
>>53679276
Put it betwen .


C beginner here, anyone has a linky to documentation on how to write C nicely? (Not talking about syntax or logic) I mean how to format my text so when I give it to someone there is a larger chance they'll understand and that you won't bitch about it.
>>
>>53679046
IntPtr temp;

Fug is IntPtr?

As for your question, neither: you're being inconsistent.

        temp = thePtrArray[i-1];

saves the pointer

        *thePtrArray[i-1] = *thePtrArray[i];
*thePtrArray[i] = *temp;

acts on the ints rather than the pointers. This basically does nothing of value, since temp keeps being equal to
thePtrArray[i-1]
because neither of them are modified afterwards, which means that you're basically doing that:
        *thePtrArray[i-1] = *thePtrArray[i];
*thePtrArray[i] = *thePtrArray[i-1];

This duplicates the value of
*thePtrArray[i]
into
*thePtrArray[i-1]
, then does a useless assignment.

Yes this is a FAIL!
>>
>>53679288
Yes exactly, objects are compared by reference.
>>
>>53679288
Ya right! I'm just being oblivious to builtin-types-are-special-snowflakes bullshit. Thanks!
This
&Test{}
thing you're doing won't work in my dialect of C++ tho, it seems to be reminiscent of Go. Are you a memer? Since memory management is manual in C++, you can't just do that and expect it to do-the-right-thing because there is no such right-thing to do. But you got your point across.
>>
>>53679382
js> typeof []
"object"

Fuck me!
>>
>>53679288
struct Test foo;
struct Test bar;
if(&foo == &bar) {
// ...
}
>>
>>53679276
by reading the fucking sticky
>>
>>53679403
If your'e surprised by this you don't know how javascript works.
>>
>>53673533
>Mersenne_Twister
xorshift
>>
>>53679142
Objects are compared by identity. The same thing happens in Java and OCaml. JavaScript is a terrible language, but it's doing the right thing there.
>>
>>53679433
this

and C# also does it, except that idiots like OSGTP overload the operator to make it a compare-by-value equals() call
>>
>>53679382
>it seems to be reminiscent of Go

What do you mean? The {} is simply an initializer list.
>>
>>53679326
My apologies, IntPtr was typedef 'd as int * temp.
>>
>>53679426
I don't claim to.
>>53679433
It is the case in unextensible languages who can't have a general predicate whose answer generally makes sense given the type at hand. I'm OK with the duality between
(eq? x y) (equal? x y)
in scheme or
x is y, x == y
in Python (btw Ocaml has = and ==) as long as both have reasonable names and calling conventions. I hate the dynamic call to a method whose name is only a convention and who has to reinvent the entire wheel in each case, also.
>>
>>53679551
>btw Ocaml has = and ==
Both mean identity when comparing objects.
>>
>>53679486
I agree, but you also agree that this code is uncompliant pseudocode right?
Test{} is a temporary value, and temporary values can't be adressof'd. This syntax is however special heap-allocate+initialise sugar in Go.
>>
>>53679582
Oops, you're right. It's incredibly dumb tho.
>>
>>53679551
Well, objects in javascript are just a map with strings as keys.
foo.bar

is really just sugar for
foo["bar"]

An array is just an object with numbers for keys (and some behind the scenes optimization)
>>
New thread: >>53679663
>>
>>53679638
>I agree, but you also agree that this code is uncompliant pseudocode right?
Yes I do agree.

>This syntax is however special heap-allocate+initialise sugar in Go.
I wasn't aware, I hadn't had a chance to give Go a try yet.
>>
File: 1373246182599.jpg (264KB, 1024x807px) Image search: [Google] [Yandex] [Bing]
1373246182599.jpg
264KB, 1024x807px
>>53679659
>>
>>53679688
You should. Not that there's anything really new with it (Maybe if you don't know message-passing programming yet), but it's nicely engineered to correct the quirks of 40yo C. The docs on the official website are enough to master it, I would advise. It really makes you look at C in a different way (that is: confuse the hell out of you syntax-wise). I use it for prototyping and quick testing of algos, since it is very handy in that regard.
>>
>>53679452
>except that idiots like OSGTP overload the operator to make it a compare-by-value equals() call
It's either that or write your own equivalency check method for the object.

I don't see an issue with it. It won't affect any implementations outside of the library, if distributed.
>>
>>53679403
[] instanceof Array;
>>
>>53679811
if the person using the library can't even assume something as banal as the behavior of ==... that's fucking retarded
>>
>>53679838
I agree, unless the object is immutable.
>>
>>53670052
rool
>>
File: Saint-Martyr-Tim-Hunt.jpg (876KB, 2060x1236px) Image search: [Google] [Yandex] [Bing]
Saint-Martyr-Tim-Hunt.jpg
876KB, 2060x1236px
>>53679838
You argue that because it is an builtin operator with builtin syntax, then it should only do basic class-agnostic things? That's dumb.

It's almost as if POO languages have two layers: the basic C-like primitives, where + and == can be used, and the POO thing stuffed on top, not integrated which is kind of odd, within which one has no way to overload + and == even in case one's life were on the line, no really what the fuck? C++ does it right IMO.

When switching from one memelang to another, you Pajeets have to ask yourself whether string is primitive before you can even start doing the most basic operations, how is that not a stupid drawback?

At the very least least, we could decide that, since "ugliness is a feature", the designated basic predicate that only checks whether two references point to the same object and basta should have a real shitty name like
__builtin__java__jvm__reference__equality__predicate__(
so that == can be fucking POO and polymorphic, right?
>>
>>53680088
for fuck's sake, operators are a core part of the language, they should behave predictably. methods are enough.

i'm not going to have this "discussion" with your retarded sperg ass for the trillionth time btw
>>
>>53680141
What the fuck is so special about operators besides syntax? Besides, you implicitely admit that there is the so-called "core" language, and the object oriented part which arbitrarily can't use the nice syntax. Again, this is DUMB! Also, my question again: how is it not a nuisance not to know immediately whether
prompt_user() == "yes"
will just do-what-I-mean and compare the content of the strings, or just subtly stop at reference-equality in a hugely counterintuitive way?
>>
>>53680253
ba ba, ba ba, ba ba
>>
>>53680293
Holy shit you convinced me you 5 year old shit-slinging kid. Now get off this site, it is reserved for adults, your mom will be angry.
>>
>>53680314
yes you won this fascinating debate are you happy now
>>
File: liberty-stops.png (4KB, 276x386px) Image search: [Google] [Yandex] [Bing]
liberty-stops.png
4KB, 276x386px
>>53680353
Fucking rebel yourself baby: your mom is indoctrinating you into separating the world between objects and primitives, whereas we could all be united as equal by the love for the neighbour. Really: quit this fucking sect and go live on your own, you're old enough. She won't adress my points because she can't, she's just brainwashed, sadly.
>>
>>53680314
Don't reply to the car poster.
>>
>>53680430
your butthurt has reached astronomical levels
>>
>>53680451
Your age: >>53680293
Adults talk, kid.
>>
>>53680479
yeah adults bikeshed about language features they wish they could change to suit their retarded personal preferences
>>
>>53680451
I am >>53680088 and I agree. Now can we please go back to whether the mainstream OOP equality operator behavior makes sense or not? Spoiler: no
>>
>>53680503
what do you even hope to accomplish, at best it's just a form of masturbation to delude yourself into thinking you're smart
>>
>>53680503
This is what happens when you reply to shitposters like the car poster.
>>
>>53680501
Should we blindly accept the language designer's decision and not question it in any way? Lisps to the win for programming freedom! Besides, it's not even a metaprogramming issue: what we are discussing is which design between saying that == always compares references and saying that it's behavior can be adapted by classes is the best, and you've made exactly
presentedArgumentsCount.equals(0)
this far.
>>
>>53680580
int *ptr1 = NULL;
int *ptr2 = NULL;
printf("%d\n", ptr1 == ptr2);


what's so hard about this?
>>
>>53680590
You're off topic, fuck off
>>
>>53680607
literally retarded
>>
>>53680607
Object obj1 = null;
Object obj2 = null;
out.println(obj1 == obj2);


waaahhhh 2 hard 5 me xd
>>
>>53680607
butthurt lol
>>
>>53680608
I know that in C, the comparison operator applied to pointers checks the pointers, not the referenced object, thank you very muck jackass. I know that if it did the opposite, this would segfault. But C is no high level object oriented language, and C++ has the same traits as C because it's C++, but since we are talking about Java, Javascript, PHP, Python, Ruby, WHAT'S YOUR POINT???

>>53680638
I KNOW, I'm telling you, I argue that there should be a way to make operators call user-defined functions like in Python or Haskell because it's cleaner. If you're not convinced, try using a Java bignum library, I remember some awful code being posted on /dpt/. Now do you have a fucking point or not?
>>
>>53680684
>Python or Haskell
>cleaner

AHAHAHAHHAHAHAA

AHAHAHHAHA

AHAHAHHA

AHAHA

HAHHAHAHAHAHAHAHAHHA
>>
>>53680684
fucking retards, operator overloading is NOT cleaner, and most real programmers don't use bignums, it's a complete corner case and it's not even inconvenient to use bignums without operator overloading
>>
>>53680590
It's not similar. In C pointers are not references, they are just values.
>>
>>53680724
references are also values
>>
>>53680735
And every variable is a reference. Retarded.
>>
>>53680698
If it's because their syntax uses significant whitespace, then
>>>>> tryruby.org <<<<<
You stupid. In Ruby, everything is an object, and this is the way to go if you want to keep things simple at the language level IMO.
>>
>>53680777
your'e retarded
>>
>>53680790
>le le no U XD
You lost sir, you just lost.
>>
>>53680805
yes, yes, now go on playing with your meme lang
>>
>>53680580
>Lisps to the win
Lisp has 4 different equality functions and none of them do what you want.
>>
>>53680721
> if it is not part of the tools I packed into the language, it is a corner case which real programmers don't need to worry about.
Are You God Omniscient?
>>
>>53680840
You favorite memelang has only one, it is an operator, and it is fucking useless. Your move.
>>
>>53680844
millions of pajeets have no problem with it. you're stupider than a pajeet.
>>
>>53680876
My favorite language has overloadable equality and a separate identity operator.
>>
>>53680880
Scheme Herrenrasse here. You know that Pajeets would litterally eat shit off the sidewalks if they were told to, so this proves nothing. I like my language to be adaptable, programmable. Fixed language designs can't fit everyone, every cornercase on which you shit, so language designers have to open the door, so their work can serve as the basis for something specific, instead of having everyone reinvent the wheel endlessly. See https://panicz.github.io/pamphlet/ for illustration.
>>
>>53680902
I agree, scheme does, python does, it's good. Java kind of does, provided that you use the shitty workaround which is being discussed here.
>>
>>53670052
roll
>>
>>53670052
roll
Thread replies: 360
Thread images: 28
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK