/dpt/ - Daily Programming Thread

Old thread: What are you working on Sup Forums?

Other urls found in this thread:

amazon.com/C-How-Program-Paul-Deitel/dp/013299044X
gist.github.com/chaitanyagupta/9324402
bookshelf.jp/texi/onlisp/onlisp_14.html#SEC95
twitter.com/NSFWRedditImage

FizzBuzz

Give me a small language that runs on JVM or CLR

C as in Christ

C as in Communism

C as in Cock

rembulan lua

C is for Cucks

Lisp seems like a lot of fun to program in, with such an elegant implementation of lists and recursion, but the rest of the syntax is kind of fucking annoying. I wish there was more syntactic sugar as an alternative to parens for things besides lists. It's a huge barrier for me to remember how to order all the statements with such minimal/reused syntax while learning the real, actually interesting challenges of programming in it. Are there any dialects that have more syntactic sugar for me to start with until I'm comfortable enough to the original syntax?

Even in that case you are still dealing with 3 separate arrays of value. How do you plan on merging such data? Gaussian?

I remember a project of a better libc that Sup Forums was making a couple years ago. What happened to it?

i'm not sure what you mean. i'm simply claiming that there are equivalent AoS representations for the SoA representations you're talking about. the values are heterogeneous regardless

Doing java homework :(

Is this one good?
amazon.com/C-How-Program-Paul-Deitel/dp/013299044X

What's the best backend framework to connect an Android app to an external NoSQL DB?

>not just using sqlite
hipster code artisan pls

Say I had a scene in a videogame and I wanted to do a more proper render of it.
Would it be possible to capture all the VBOs and opengl calls to replicate it so I can change shaders etc?

What defines a real programmer?

Google "Common Lisp Reader Macros" and make your own syntactic sugar.

Hashtables are a common place to start. I HATE writing (make-hash-table ...) (setf (gethash....)) stuff.
But after a reader macro, it's much easier.

Here's a decent starting point:
gist.github.com/chaitanyagupta/9324402

Let's you type JSON into lisp and get hashtables back out. I'm certain you can make your own easy-to-use reader macros for other stuff.

Also, remember that arrays are #("elements" "in" "the" "array").

my goal is to acquire currency, what's the best way of going about that with programming?

I had a job interview yesterday and they told me they'll probably switch to angular JS.

How is angular js ? Any experience ?
I'm used to code in C, C++, javascript, php if that matters

Thank you, this is just the kind of thing I'm looking for.

Why do people say functional programming is more scalable than OOP? It seems like in a lot of cases, expanding the scope of a project requires rewriting a lot of code if it's written functionally.

The ability to sit down and lose yourself in the joy of programming for hours :'3

get a job

How is SQLite going to help if something needs to be stored offsite?

>learn Haskell
>post it as a skill on LinkedIn
>have to get a 2nd phone line installed because recruiters are calling 24/7/365 offering 6-figure jobs now

>What defines a real programmer?
If you'd rather spend 2 hours automating a task than 1 hour doing it manually,
you're a real programmer.

tfw you can program functionally in c# and it's way more fun than default c#

What do you mean? You want to poll a website for some DB to present to your user?

Just use a http request and send a JSON DTO, and on server-side use whatever you're comfortable with (php or whatever) to consume the request and update db as required

Should I take an offer for a company that pays shit and looks dreadful to work for, but it'll be an actual developer position, or should I keep looking for somewhere I'll want to stay at for more than 6 months?

Depends on how urgently you need money.

never take a job that doesn't suit you unless you really need the money/exposure/experience/whatever.

You can get the same cred as a developer by hacking open source

Well, satan, I don't particularly need a job ASAP, but I'm worried that if I don't take something soon it'll start to look bad since I graduated last year.

Self learner in c# here, need help with this problem (doesn't need to be in c# tho)

We are given 5 integer numbers. Write a program that finds those subsets whose sum is 0. Examples:
- If we are given the numbers {3, -2, 1, 1, 8}, the sum of -2, 1 and 1 is 0.
- If we are given the numbers {3, 1, -7, 35, 22}, there are no subsets with sum 0.

Who is this semen extractor

animeposters need to die

First write a program that can find all subsets of a given array and return it as a list then iterate over that list and call .Sum on each.

Anime website

>doesn't know who that girl is
>""""""""""""anime poster""""""""""""
No.
also,

Hm, i'm gonna look into that, lets see if i can find all subsets of an array

>how to order all the statements
Examples? This is ambiguous to me.

It's not, and anyone who thinks so is just deluding themselves.

functional programming is easily multithreadable. since you put a value in and then just get a value out with no side effects, you give your function its value then fuck it off to the side and it can do its thing while you can process other stuff while waiting for it.

in other paradigms it is possible and probable that this function could modify things that will interrupt/break the other things you're working on while waiting for it but with functional programming this cannot happen and the programmer doesn't have to worry about it.

Why is it always a libc? Who even cares about that legacy shit? I'd rather the kernel developers wrote a liblinux so I could easily make system calls. MUCH better, no need to desl with absolute bullshit like errno.

M-x butterfly

Except that mutating data is 90% of what users want to do.

Use dynamic programming.

Next level: solve the problem without calculating the power set beforehand (space complexity of O(n) instead of O(2^n)).

Protip:

yea. it seems like these days a programming language is judged by how well it stops you from doing the bad shit than how much it allows you to do the good shit

Would C be useful for an electrical engineer?

Do you know? pls tell

pure FP ⊂ FP

Yes, in the case you were designing microcontrollers. You are most likely to expose your microcontroller pins through C headers than letting software devs struggle with binary and/or assembly.

express the powerset as a graph and then do a complete walk through it, expressing .Sum on each node.

This really isn't that hard.

> expose your microcontroller pins through C headers
What did he mean by this?

this argument again

looking through old company code
>string sadd = "&apt=" + 6.ToString();
made me laugh

take it and look for another job. be gone at the 6 month mark

Pins are I/O. Each pin corresponds to a register. In the C header, you give each register address a name.

There, you have exposed your pins through a C header.

of course it isn't hard.
it's literally like a chapter 8 question in a learn programming book you tryhard

What if my learn programming book only has 7 chapters?

Can I get some help with my program?
I'm trying to simulate the spinning of a roulette wheel, and I want the numbers that are printed on screen change really fast at first, then slower as they approach the result. I have an array containing all numbers 0-36, ordered cloclwise from 0, just as an actual wheel. I use random to determine the outcome. I'm not sure how to display them correctly. The wheel always makes two spins at least.

>expose
why this word?

C is immensely valuable for an electrical engineer because almost all mcu programming is done in C in 2017

That doesn't help at all

Yes it does. It is literally the "subset sum problem" which is easily looked up. You just have to modify it so it finds all of them.

>Butt devastated that his question wasn't hard
>namedropping chapter 8

legit though 3rd year algorithms is really fun.

Express the wheel as a reversible function with an input from 0...1 and an output from 0...1

Apply an easing function like sin(x)

Being able to write useful programs.

Bonus points if you get paid for it.

is this a graphical application or a console application?

It seems like anyone with a little experience wouldn't be retarded enough to multithread processes that will break each other. Is there anything else?

Is this a good way of dealing with the consequences of removing IO from a language? I'm thinking of making some sort of system which does all the needed IO at compile time and just bakes the results into the binary. So the program itself doesn't have to do IO.
The first compiler itself obviously would have to do IO, but it can be compiled in a similar way once it's complete.

I don't understand. This is probably the simplest thing that I overcomplicate.
Console.

jesus christ

That makes no sense.

Thanks for your shitpost.

this is too far

What happened?
Why is that?

C++ Template Metaprogramming can do that.
They're Turing Complete at compile-time.

What if a user or program must provide additional information to the program?

What if this additional information is a result of information your program has generated?

>multithread processes break each other

Those words don't mean what you think they mean.

Writing a multithreaded process that requires a persistent set of data (i.e. multiple users hitting a database... i.e. every web application ever) is inherently a difficult thing to do with multiple concerns.

I'm not advocating FP as a solution to this. It hasn't been solved properly since the 70's. It's just hard and will almost invariably break in a way you don't expect. And that's before people start TRYING to break it (see : heartbleed)

It doesn't even have to be Turing complete.
C++ is garbage though and I wouldn't be either using it or writing a compiler for it.

Then I guess he could do so and the results of that would be compiled into the binary once again.
>What if this additional information is a result of information your program has generated?
I'm not sure I understand you here. Why would this be a problem?

Lisp macros can do computation at compile-time. bookshelf.jp/texi/onlisp/onlisp_14.html#SEC95

right, so you need to do this in a loop

int delay_time = 100
while (spinning)
{
print_num(num_ary);
delay(x)
delete_num()
if (spin_time > xyz)
{
delay_time += 20
}
if (delay_time == 1000)
{
spinning = false;
}
}

Report, hide and ignore the troll.

That will have varying speed, depending on the system.
You need to solve it analytically

This sounds like you want to write an interpreter rather than a compiler.

I can't imagine a user WANTING a binary that generates "what is your name" and then after answering, a new binary is compiled, that the user has to run, that prints "Hello !"

Why are you so angry? Do you need a glass of water or something?

depends on the promises your language makes in its delay() function. If delay waits for different times based on your cpu speed then grab that and convert ticks to millis, then apply above solution.

How do I into functional programming?

Coming from Python.

how do i find sums of all subsets in an array?

You can into functional programming with Python.

Learn you a haskell or the haskell wikibook.

var sumOfAllSubsetsOfMuhArray = muhArray.AllSubsets().Select(x => x.Sum());

Python is neither functional nor functional.

Considering you seem to know LINQ, can you explain wtf the fuck is going on in this solution of this problem

It works but i have no idea how it finds subsets of an array

int[] source = new int[] { 1, 2, -3, 4, 5 };
for (int i = 0; i < Math.Pow(2, source.Length); i++)
{
int[] combination = new int[source.Length];
for (int j = 0; j < source.Length; j++)
{
if ((i & (1

>depends on the promises your language makes in its delay() function. If delay waits for different times based on your cpu speed then grab that and convert ticks to millis, then apply above solution.
The code around the delay() won't execute at the same speed on every CPU, not even on the same CPU on an OS with preemptive multitasking

Let x be a range from 0 to 1. You can divide this up into however many steps you want. Say if you wanted 20 iterations, just set x to 1/20 and continuously add 1/20 to it and loop while it is < 1. Let y be the time your program should sleep/delay/etc. In , they use y = sin(x), but other functions could work too.

only in the theoretical sense. C++ doesn't expose any way to do IO at compile time. also worth noting that much of template metaprogramming is made unnecessary by constexpr

Compilers let you define macros on the command-line, which is a form of I/O