/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread: boards.Sup Forums.org/g/thread/63948482#top

Other urls found in this thread:

github.com/rust-lang/rust/issues/46889
twitter.com/SFWRedditVideos

carryover from end of last thread:

Second for Kotlin.

hi guys hows my web

oh and also hi ruby

...

Just found some old code from around when I first got started learning to code. Tell me what you guys think. pastebin.com/sBn1A4C6

>comma not inside a backquote
amazing

that snippet is inside a backquote

I'll roll on this one.

please help
going crazy over this

just updated VS2017
now when i go to create a new project/solution
it doesn't build the basic files for all platforms

wtf is going on?

why should i learn and use monads?
i can do all the maths with basics of pretty much any language

Is there a tool out there that can find and output comments in source code that were tagged a certain way?

In the comments of my code I like to put "@TODO" or "@Hack" or "@Release" to signify something actionable.
Now I want to quickly search for these things. Previously I used regex, but it's not good enough, I'm looking for something specifically tailored for this problem.

monads are cool

>monads are cool
explain

they let you do cool stuff
you know when you manipulate procedures and stuff? callbacks, putting them in data structures, etc?
that's the sort of cool stuff you do with monads

Retarded pedantic name used by people who don't even do homological algebra.

can't i do all that with classes and functions/methods without monads?

for IO specifically yes, though monads is more about the recognition of it as a special thing and as the thing being done

monads are more general

>Moan ads

yes, you can write programs with entirely functional code in c++ or python, for example
they're multi-paradigm languages, after all

STOP TALKING ABOUT m'nads
they are MY nads, not YOUR gonads!
friggin' perverts!

they're bi nads now

For example a callable that returns a new object can be seen as a monad

Maybe t = Just t | Nothing
vs
Option t = Some t | None
Haskell devs truly are retarded

>not using the patrician Option t = Some t | Nothing

dumbass

Maybe y = Just y | Nothing
MUCH better

#include "list.h"

struct node *
add_to_list(struct node *head, struct node *n)
{
struct node *p;

p = head;
while (p->next) {
p = p->next;
}

p->next = n;
n->next = NULL;
return head;
}

struct node *
remove_from_list(struct node *head, struct node *n)
{
struct node *p;
struct node *p_prev;
p = head->next;
if (head == n) {
head->next = NULL;
return p;
}

p_prev = head;
while (p) {
if (p == n) {
p_prev->next = p->next;
p->next = NULL;
break;
}
p_prev = p;
p = p->next;
}
return head;
}

void
print_list(struct node *head)
{
struct node *p;

p = head;
while(p) {
printf("%d->", p->data);
p = p->next;
}
printf("end\n");
}

int
main (void)
{
struct node head = {NULL, 1};
struct node next = {NULL, 2};
struct node *p;
add_to_list(&head, &next);
p = remove_from_list(&head, &next);
print_list(p);

return 0;
}

>Maybe
>Just

>oh no i have to type three more chars even though most plugins will have auto-complete after the first 2-3 anyway

t? = t | Null

>Not being a two star programmer
Try again.

>implying it's about the amount of chars and not the retarded naming
Haskeltoddlers lmao

Rolling for tomorrow

_? t = _. t | .

don't even use haskell m8

>scheme is a bad langua--

I feel like I'm intermediate with Java now. Do I start learning Clojure or Scala next?

did you make this? good OC
people haven't made much OC lately

Should I bother reading SIPC or is it a meme? I've been a professional for a decade but never read it

thanks, perspective tool saves lives

do you want to learn scheme
that's literally all you need to ask yourself

i've never read it either, i just wanted to make a scheme-meme
so i also have this question

question, is sicp still useful if you know scheme
i wouldn't even be coming into it from an imperative background, scheme was my first language

Quick, write a macro for this.
(rplacd (assoc 'x lst) x)
(rplacd (assoc 'y lst) y)
(rplacd (assoc 'z lst) z)

sure, you learn a lot. and it's all taught in scheme so you could brush up

I don't mind, assuming it will at least teach me to solve problems in a different way

I own it. New 2nd edition paperback. Best book on my bookshelf. Skimmed through it while watching the lecture series (20 very good lectures with magickal nostalgia feels) and read the first few chapters in detail. Haven't started with any of the exercises. It really is good for all levels of programmers.

struct node *
remove_from_list(struct node *head, struct node *n)
{
struct node **pp;
struct node *p;
pp = &head;
while(*pp) {
p = *pp;
if (p == n) {
*pp = p->next;
}
pp = &p->next;
}

return head;
}

...

vv < <
2
^ v<
v13v4
^ ^
> >?> ?>5^
v v
v97v6
v v<
8
> > ^
vv < <
2
^ v<
v13v4
^ ^
> >?> ?>5^
v v v ,*25

>muh "moan ads"
>muh "lamb duhs"
>muh "ass lel"
Why do H-ass-kill girlmales think it is a good idea to prove to potential boyfriends what good programmers they are by producing "moan ads" in which they embed ads of them moaning into their kode komments? It's true, ask any asslel girlmale about "moan ads," (((((((((s))))))))he will immediately moan at you.

Pic related: a screencap of an illicit """moan ad"""""" extracted from ass-lel source (((k)))ode

(USER WAS BANNED FOR THIS POST)

owo

>copying the structure, but adding a change
>instead of adding the change to the original structure

>(USER WAS BANNED FOR THIS POST)
that's a rare one

>(USER WAS BANNED FOR THIS POST)
Butt-blasted ass-lel mod detected. Also, kek.

>(USER WAS BANNED FOR THIS POST)
Come on, user: you really were shitposting way too hard.

hot.

>(USER WAS BAND FOR THIS POST)

puns aside, next time you get a little too excited about how appropriate your pic related is, remember to stop and make sure it's not porn

gg no re

You deserved that you fucking queer.

MODS = GODS

Complete Java novice here. I'm trying to learn Java for fun, and I tried to write a help system program for organic chemistry concepts. The program right now just has placeholder names. When I run it and go through the system initially, it works, but when the program iterates to process another request, it goes kind of weird. What am I doing wrong?

Here's the output.

Reminder that this is the correct way to read a line of indefinite length in C.
#include
#include
#include "readline.h"
char *readline(FILE *fin, int term) {
if (feof(fin)) return 0;
size_t size = 0, cap = 256;
char *retval = malloc(cap);
int c;
while ((c = fgetc(fin)) != EOF && c != term) {
retval[size++] = c;
if (size >= cap) retval = realloc(retval, cap

C was a mistake
ML was robbed

it didn't have to be like this

#define _POSIX_C_SOURCE 200809L
#include

int main(void)
{
char *line = NULL;
size_t len = 0;
getline(&line, &len, stdin);
free(line);
}

...

in Haskell this is just
getLine

In cat this just

in bash this is just

No, in bash that is just
read

>Brainlet writes C

read var

>Ruby eternally btfo
ftfy

Gonna be honest, senpai. This code is a train wreck all around. Some major points of focus:
1. Fix the conditional in your first do-while loop. You're using bitwise logic operations. However, & is NOT the same as &&. Same goes for |. This is probably the reason you're looping, but if not its might be because you didn't clear ch1 after it was used.

2. Don't use for(;;). Use a while loop with a conditional like while(helpSystemRunning), where you change the bool where the break in the loop is instead of breaking out of it. If you don't want to use a bool, then at least use while(true) and break out of that. Don't be a retard and use for(;;).

3. Read up on hash maps. The hard-coded strings and printlns you're using right now are going to be a GIGANTIC clusterfuck when you get a decent number of menu options.

I don't get this In C this is in !C this is just meme.

in Haskell this is just
($)

It's just shitposting, you shitpost in response or ignore it.

One cool thing bash read can do though that your average input function can't is:

read -e input

Readline is already in the bash source. Line editing kicks ass.

The reason it's difficult is that GNU readline is one of the few libraries that are actually GPL and not LGPL. It's a licensing problem, also libedit sucks ass.

Many languages are forced to make their own or require the user to explicitly enable readline.

>This code is a train wreck all around.
Really? My program is really just based off an example the book I'm studying off of has. I just tried to add to it and make it more thorough for organic chemistry concepts. Is the book's program poorly written?

Yes it is, but that's a beginners exercise so you can't expect much from it. Keep reading the book.

Writing some Elixir for the first time. Like alright so far, will report back in 2 weeks once I finish this initial project on my thoughts.

Started looking at erlang but the consensus (after reading opinions and differences) for me was to just use elixir straight off the bat.

In sh this is just /dev/random > /dev/null.

Hey nerds girl here (=
I got an idea for a game just looking for someone to make it

OK, so first, how would I fix my program so that the iteration in the output doesn't look so weird? Second, for my own curiosity, can you post a well-written version of this program?

>just use elixir straight off the bat
If you are a rubbyfag, then yes.

I'll do it for $50,000. and 75% of all revenue.

>idea for a game
all games possible have already been made.
only alterations of existing games are now possible

People are just poking fun at C for not having better defaults.

I'm not a fan of ruby and its syntax, but the docs + things like atom syntax, sigils and macros just seemed a bit nicer.

Given the size of what I'll end up writing it doesn't really matter which I pick since conceptually they are practically identical.

Funny but serious replies only (=

i am serious.
you have NOT come up with a game idea that hasn't already been done.
PROVE ME WRONG

There is no well written version of this. The input menu you have is common for introductory tutorials but no actual program is written that way.

In a cli application you either use command line arguments or in cases where you operate on an entire input file, stdin(usually piped from the shell).

The only way I can see your program is demonstrating how to use switch/case. For that it's fine but isn't a good way to deal with user input.

It's like a JRPG but with a bit of Skyrim
That's all I will say tee hee
I need someone to program and make art

I will actually implement your game for that though.
Considering I'm doing all of the work, it's only fair that I get most of the profits.
I'll also need an upfront free, as somewhat of a security.

Ummmmmm no
also why are you replying to my trolling
post progress

/agdg/ strikes again

github.com/rust-lang/rust/issues/46889
Noice.

Why are we letting OPs who can't even link properly make threads?