/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

en.wikipedia.org/wiki/Infinite_monkey_theorem
twitter.com/AnonBabble

sml or ocaml?

Reposting because I'm an attention whore. Rate my fizzbuzz:
DECLARE N INTEGER
DECLARE F INTEGER
DECLARE B INTEGER
N = 0
F = 0
B = 0
FB: IF (F = 3) THEN PRINT("FIZZ");
UNLESS (B = 5)
INWHICHCASE PRINT("FIZZBUZZ");
ELSE UNLESS (B = 5)
INWHICHCASE PRINT("BUZZ");
PRINT(N)
DON'T UNLESS (F = 3) F = -1;
DON'T UNLESS (B = 5) B = -1;
F += 1;
B += 1;
N += 1;
DO UNLESS (N = MAX);
REPEATFROM FB;

All programming is trash.

In this thread, we continue discussing why Scheme is superior to every other vermin-tier language. Scheme brothers, unite.

>Procedural: My code is completely unmaintainable spaghetti, but at least it gets shit done.
>Object-oriented: I have thousands of lines of code that don't do anything, but at least it looks nice.
>Functional: Nobody can read my code and it doesn't get anything done, but at least I get to feel smug about it.

does this sound about right, Sup Forums?

t. mac toddler

Dataflow programming is the future

>FP is somehow not a subset of either procedural or POO
not even close.

b r a i n l e t

Please, post a working version of code.
The purpose is to read some lines, and after the EOF, print those, which are more than 30 chars long.

#include

#define ARRAYMAXLIMIT 2000
#define INPUTMAXLIMIT 500
#define CHECK 30

int inputline(char line[], int lim);
void copy(char to[], char from[], pos);


main ()
{
int len;//lenght of array
int lim;
char line[INPUTMAXLIMIT];
char overall[ARRAYMAXLIMIT];

while ((len = inputline(line, INPUTMAXLIMIT)) > 0) {
if (len > CHECK)
copy(overall, line, len);
}
printf("%s", overall);
return 0;
}


int inputline(char s[], int lim)
{
int i, c;

for (i=0; i

Oh god I have no idea what I'm doing, someone please tell me how to lex

I'm trying to parse strings in a file and cleanse punctuation:

for (i=0; wordcheck[i]; i++)
{
wordcheck[i] = tolower(wordcheck[i]);
wordcheck[i] = strtok(wordcheck[i], ",.?");
}
fseek(fp1,0,SEEK_SET);


when I implemented the code tolower everything worked perfectly fine, however when I use strtok it produces compiler warnings and crashes when executed:

main.c
main.c(86) : warning C4047: 'function' : 'char *'
indirection from 'char'
main.c(86) : warning C4024: 'strtok' : different t
actual parameter 1
main.c(86) : warning C4047: '=' : 'char' differs i
ion from 'char *'

11th for Typed Racked is pretty fucking neat.

is the type system actually good though?

float Q_rsqrt_distance(glm::vec3 vector1,glm::vec3 vector2){

// remove this and it will not be reliable{
float value = abs(
(vector1.x-vector2.x) * (vector1.x-vector2.x)+
(vector1.y-vector2.y) * (vector1.z-vector2.y)+
(vector1.z-vector2.z) * (vector1.z-vector2.z)
);
if(value

Don't use that language to do it. Use something higher level.

Anyone here know if this riddle is based on coding?

???????

Scheme is truly a language for the white man.

First of all, I would suggest reading up on fseek() instead of caching all those lines. You can skip back and forward like that easily.

It's a good type system, but not practical because few libraries use it. It's the same problem as with Typed Clojure, except Clojure has more libraries.

I really want to accomplish the task with the knowledge I've been given and nothing more than that, otherwise there is not point in exercises and it would have been better to switch to Python to do this.
I want to learn.

what do haskellfags think of how functional programming will be remember as nothing more than a way to save space in java?

Racket is still fairly new, they only just got their package manager ironed out a few months ago, right? Most of the newer libraries I've seen use typed racket and I'm pretty sure most of the built in libraries use it.

>that English
>java
I don't even know which "country" this post was made from

Why do you calculate value twice?

Also make sure to compile that with -O3, I think gcc will vectorize the whole thing for you.

triggered

Here, my friend, is a working version of code.
(do ((l (read-line t nil 'eof) (read-line t nil 'eof)))
((eq l 'eof))
(when (> (length l) 30)
(print l)))

kys, my friend.

Another fucking SPA web app that I make for a living.

C is the best thing ever to happen to humans
C is love
C is life

Racket (formerly PLT Scheme) is pretty old. It just never took off as a practical language. A package manager might help but I wouldn't bet money on it.

Fair enough, it is about as old as python/java. Seems to me that it's only just started to really take off in the past 7 years

Came out 1994.

The fact that the packages aren't called 'Rackages' (or some similar pun) is a constant disappointment to me.

Do any of you guys take amphetamine?

I did at the time. Didn't help programming, desu

>The fact that the packages aren't called 'Rackages' (or some similar pun) is a constant disappointment to me.
You are disgusting.

>studying for 8086asm exam
>its a write a matrix function question

You fucking love it.

Where do I buy an APL keyboard?

Anybody got any ideas for this one?

floating point?

nah, we take spironolactone

I'm planning on buying some this summer, and using it to aid me in learning programming. Tips?

Is there an algorithm for creating an infinite amount of PNGs? If so, would it technically be able to produce screenshots of anime which haven't even been created yet?

>Tips?
Don't.

en.wikipedia.org/wiki/Infinite_monkey_theorem

>spironolactone
>is a medication that is primarily used to treat fluid build-up due to heart failure, liver scarring, or kidney disease.
wat? is it a nootropic also?

Just use high dosages of caffeine. It's pretty good for beginner programmers.

look at this guy

Time isn't an issue for me.

It won't help. You'll want to go outside and smash someone's face, you won't learn anything.

Not only that, but it would make every single frame of every anime anyone could ever make, as well as pornographic versions of every single anime.

What about microdosing

> microdosing amphetamine
It doesn't work like that. If you don't take it all, you're probably dead.

Now I just have to finish my time machine written in Haskell and I'm all set.

What's a stable way of implementing the hyperbolic cotangent in C++ for small increments of the argument? Is 1/tanh(x) better? Or cosh(x)/sinh(x)?

I used to, did help with programming (concentration, not motivation) but eventually quit because it really cranks up my anxiety levels.

I'm learning Python and coming from Ruby I can't say it has been a pleasure so far. Either way here's something that confuses me a bit:

def double_first(n):
n[0] = n[0] * 2

numbers = [1, 2, 3, 4]
double_first(numbers)
print numbers


Here a list is passed as the argument to the function. But when the function uses a parameter, it is just the same object??? The code above outputs [2,2,3,4], meaning that the function modifies the original array despite it being the parameter "n" being modified.

You pass a reference to a list in to the function. It's the same object but a different reference to it.

(number of colors that exist)^(amount of pixels) = number of possibilities

you could do it with nested for loops :-)

ok that seems like something to keep in mind as not to accidentally modify an object when you pass it into a function

#include

int main(int argc, char const *argv[])
{
Tcl_Interp* tcl_interp = Tcl_CreateInterp();
return Tcl_Eval(tcl_interp,"\
puts [join [lmap s [split [read stdin] \\n] {\
if {[string length $s]

>Procedural: My code is completely unmaintainable spaghetti, but at least it gets shit done.
Assuming you've just started learning, yes.

>Object-oriented: I have thousands of lines of code that don't do anything, but at least it looks nice.
Yes

>Functional: Nobody can read my code and it doesn't get anything done, but at least I get to feel smug about it.
Yes

>Back to procedural
Eventually you realise that modules with free functions is a superior programming model to OO, and you just write procedural code but with better structure than before.

>C++
Didn't read past this point.

>FP is somehow not a subset of either procedural or POO
opinion discarded.

2 out of those 3 are unmaintainable. Doesn't matter if it takes 5 times the time to write it, if it takes 1/100th the time to maintain it.

...

not entirely programming related but I need to set up PXE so I can boot and debug my own kernel in virtualbox.
how do I get started?

is this some new reddit meme?

C-could I generate the best porn that will ever exist?

Asking for a friend...

Used to. It does help temporarily but the price is too high.

Yes.

We love it.

Is there any reason for me to not focus on the entry level stuff like java and various C versions? The way I see it I'm rarely going to be able to choose what I use in a job so it makes sense I should be able to make things work even in languages that are a bit more difficult to manage.

>various C versions
what did he mean by this?

Yes, do you like it?

It would generate every possible image so yes, but since the best porn would be at least 4k resolution and 32-bit colour, you're looking at 3840*2160*32=265,420,800 possible images. Finding the one you want would be pretty difficult desu

It's a fucking diuretic and antihypertensive that occasionally causes gynaecomastia.

Sensible traps take actual hormones, not that shit.

Switch and case statements are the devil.

What do you want? A jump table? A branch chain? Neither somehow? Well, leave that to the optimizer! Semantically encoding assembly instructions is for the dogs! C is an APPLICATION PROGRAMMING LANGUAGE, nerd.

"I don't care that your case values are sequential and that you are running this in a tight loop, I'm not gonna generate a jump table!" -- GCC v4.9+

Chew nicotine gum.

If you want something stronger, get that oromucosal nicotine spray and put half a dozen spritzes under your tongue. Hits you like a hammer.

Isn't it
>32^(3840*2160)
?

Yes, my mistake

(2^32)^(3840*2160)

Inline assembly rang, it says you never called it.

Please don't disrespect my heritage by culturally appropriating our national icon and attaching it to such an awful programming language

Is that our national icon? I thought it was Michael Palin or something.

Maintaining a port-specific file for each combination of compiler and architecture doesn't sound all too fun.

It's Britannia you uncultured fuck

In C++, how do I return a pointer to an object from a function (the object being created in the function body) without returning a dangling reference?

laravel site. Is taking forever to learn the framework properly. On my own, so feel like I have to learn all the information in the world.

>In C++
that's where i stopped reading, buddy

Your heritage has been disrespected left and right, and this is what you object to?

>implying i haven't objected to anything else

Didn't you like my 'call'ing pun? :(

>object
Stopped reading right here.

return a shared_ptr.

I'm kind of stuck right now and some help would be appreciated.
I'm trying to create a prompt that only pops up if a variable has a certain value, and if it doesn't have that value then the prompt doesn't show up.


var tax = prompt("Do you pay state tax? (yes/no)")
if (tax == "yes") {
var stateTax = prompt("How much?")
if (stateTax >100 ||

You'll find the British don't really care when their heritage is disrespected.

It comes from not being a histrionic infant nation :)

>You'll find the British don't really care when their heritage is disrespected.
Yes. Because they don't have any.

Well, you can't use or like that. It needs to be
if (stateTax > 100 || stateTax < 0) {