/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

youtube.com/watch?v=J85OBqT51ZM
github.com/mogaal/cclive
github.com/mogaal/cclive/blob/master/src/cc/application.cpp
amazon.com/Sandbank-Panties-Translucent-Briefs-Underwear/dp/B075HF93HT
twitter.com/SFWRedditImages

what does crossdressing have to do with womans underwear? men can wear womans underwear without being crossdressers. crossdressing starts once you start wearing bras, skirts, knee socks, wigs, etc.

youtube.com/watch?v=J85OBqT51ZM
>Not using Qtcreator with proper formatter, debug tool, and linters
Why do people waste time like this

can anyone help me out with a program for my java class? the teacher gave us instructions of

 prompt the user to enter a word
 read the word
 prompt the user to enter an index into the word
 read the index
 if the index is legal, print out the letter at the given index, in the format
shown in the examples below, using printf properly. You do not need to check
for negative indices.
 if the index is NOT legal, print out an error message in the format shown in
the examples below.

but im having some trouble with the if/else part of my code

>in the format shown in
>the examples below.

format isnt what i have trouble with but here is what he provided

Example 1 (input in green):
Enter a word: Mesopotamia
Enter index: 4
In word "Mesopotamia", the letter at index 4 is 'p'.
Example 2 (input in green):
Enter a word: puppy
Enter index: 5
5 is not a legal index for "puppy".
Example 3 (input in green):
Enter a word: Xanadu
Enter index: 0
In word "Xanadu", the letter at index 0 is 'X'.

Reading about virtual functions

this is all very straightforward

put on a pair of lace panties and explain how it's not crossdressing

same

well im sorry im just trying to learn. my teacher isnt very organized in his lectures. we didnt even go into boolean operator examples and he expects us to know them.

have you guys considered supporting cclive github.com/mogaal/cclive

It can download videos from youtube and is a great project.

#include

int main() {
std::cout i;
if (i < word.size())
std::cout

>Contributors: 2
Stop shilling your crappy sepples project. youtube-dl already exists.

>C++
No thanks. Enjoy your buffer overflows.

>boost::mt19937 _rng;
why
github.com/mogaal/cclive/blob/master/src/cc/application.cpp

>define foreach BOOST_FOREACH
user, I...

swift or chapel?

C++

tetris

not programming language

>boost
thats not how you do good code senpai

Especially when some of the featues are already ported to the standard

Trying not to kill myself while programming a Android app and wearing panties and knee socks.

perhaps it's time to stop being a faggot

.charAt()

amazon.com/Sandbank-Panties-Translucent-Briefs-Underwear/dp/B075HF93HT

not sure what that does we haven't gone over that yet.

if (x == (int)x)
{
// Number is integer
}

you will also need to check that the value is within the length of the strength so x has to be less than length - 1 and greater than -1

google it then

apologies:

if x (== Integer.parseInt(x))

length of the string, fuck me

im having more trouble with the

if (index >= ?? && index < ??)

heres the rest of my code

Scanner in = new Scanner (System.in);


String word;
int index;

System.out.print("User enter a word: ");
word = in.next();
System.out.print("User enter another word: ");
word = in.next();

if (index >= ?? && index < ?? )
{
System.out.printf("In word \"$s\", the letter"
+ " at index %d is '%c'.\n", word);
}
else
{
System.out.printf("%d is not a legal index "
+ "for \"%s\".\n", index, word);

indices are 0-based in Java (in computer science, you always count from 0 - some languages are 1-based, but it's a small handful and usually because they were designed for use by people other than programmers) which means that if you don't have to worry about dealing with negative indices, you can just check that the index requested is less than the length of the word in question. (E.g. puppy is 5 letters long, but since the index of the first p is 0 and not 1, then the last letter 'y' is at index 4).

There's not much to know about boolean operators. AND (or && in java) is only true in the case where both arguments provide are also true. OR (or || in Java) is only false if both arguments are false. Boolean operators also short circuit, which is to say that if the first argument to an AND is false, it does not look at the second argument, as the result will be false no matter what. OR is the opposite - if the first argument is true, it doesn't care about the second as the result will also be true regardless of the second arguments value.

yea i get that but im just having trouble getting the print out to tell me what index the actual input word is at

Like the other user said look up on google, charAt() in Java. It's a function. Being able to look up documentation on the language you are writing code in is a huge part of programming.

You are not expected to know every facet of your language. The more you program the less you will have to look up.

if(index >= 0 && index < word.length()){

}else{

}

Confess your programming sins.

I unironically use Ruby.

no comments, ugly code
dont use enough abstraction ie functions are too large, i think

I use Python.

How do I into dependent type systems, Sup Forums? Any recommended reading?

You should be ashamed

I use a bunch of print statements while developing instead of a debugger or logging.

oh i do this too lol

I don't use a debugger, I just add temporary lines to print to the console.

I've acquired a nasty habit of cobbling shit together in a javascript browser repl. I think I'm starting to like it a bit too much.

Who / clang++ -std=c++1z -Weverything -g src/* -o /bin.out && ./bin/out/ here?

I only comment retroactively, and only if I expect that someone will see it.
I never really think about time complexity if I have a working algorithm.

Employed Haskell programmer reporting in

>go package manager doesn't support versioning of any kind
>always gets the latest from repo
What the hell were they thinking?

>sepples
>clang
dumb hipster nu-male

webdevs love to rewrite the whole project after one week

>not
-g -Wall -Wdeprecated -pedantic -Werror

What does this print?
#include
class A {
public:
virtual const char* getName() const {
return "A";
} // note: function is const
};

class B : public A {
public:
virtual const char* getName() { return "B"; }
};

class C : public B {
public:
virtual const char* getName() { return "C"; }
};

class D : public C {
public:
virtual const char* getName() { return "D"; }
};

int main() {
C c;
A& rBase = c;
std::cout Code in Rust
>Get called a hipster
>Code in C++
>Get called a hipster
What do you want me to do? C in the year of 2018?

>C in the year of 2018
C every year, the only sane choise

enjoy writing mallocs 40 times a day, grandpa

Why are Jews so good at com-sci?

CS (along with all other STEM) fags are very non-religious.

Not really programming but a pretty nice trick that is useful if you have many windows open. I want to make a proper version in the future which shows all matching windows as you type, perhaps with some fuzzy matching.

What does the "fuzzy" specifier do?

>choise

What's the point?

I am autistic.

if (truthyGrid[i].col < 0 || truthyGrid[i].col > this.grid[0].length) {
return false;
}


Is adding two more ORs to this if statement bad form?

Should I use another if statement? A switch statement won't work as I'm checking two expressions.

ie.
if (truthyGrid[i].col < 0 || truthyGrid[i].col > x || truthyGrid[i].row < 0 || truthyGrid[i].row > 20) { }

Just put them on a line each.
Or make a simple helper method called isValidIndex or something that returns boolean.

Shilling Haskell on a Filipino beekeeping forum is not a real job user.

Cheers senpaii. It does look better.

Now it's formatted, I gotta keep trying to get my collision to work.

what is your process for designing and planning the architecture of a new program?

C isn't the best lang...

Denial
Anger
Bargaining
Depression
Acceptance

2/?

3/?

>C isn't the best lang...

4/?

it is perfect tho

What library do you use unicode strings, directory walking or did you just write them yourself?

For directory walking I use dirent, I don't use unicode though, pointless to what I do.

>unicode strings
Just use UTF-8 and ignore all of the extra characters. They will pass through fine without breaking anything.
Also, the C standard library actually has functions for dealing with unicode characters.
>directory walking
This is provided by POSIX.

>POSIX
not portable though

It's portable to POSIX systems, which is all I care about.
I don't care about your winmeme trash.

>This is provided by POSIX.
Great thing I think is most works on an msys environment if someone would be concerned with portability.
There it is lmao.

this

If your compiler in windows is msys, almost everything works the same, no ifdefs. dirent.h does it perfectly under both systems.

why are you complaining? Isn't micropenis able to run POSIX apps "natively"?

I'm not complaining, I'm saying msys does it for those who I predicted would complain.

If I learn one language, how difficult will it be to move to another language?

depends on the languages

Such as?

Depends on what you learn first, if you learn a high level language, it will be easy to go to other high level ones, it will be extremely hard to go to lower level languages. If you learn a low level language first, learning other low level languages will be easy, learning high level languages will be like opening Christmas presents.

if they're similar then fairly easy

If you learn python first, learning C++ will be hard,
If you learn C++ first, learning python as a second language is very easy

That's only because C++ is unreasonably complex and obtuse.

But yeah, in general if you learn one C derivative language you can adapt to another quite fast.

>when pantsu broke because a dependency pushed code that didn't even compile to master
good language

>That's only because C++ is unreasonably complex and obtuse.
You haven't seen either of Rust or functional programming memelangs yet

Are you serious?
LMFAO

What you need to learn a language:
logic + lang paradigm + specification/libraries

If you move from languages inside the same paradigm, you'll need only to learn the specification and common libraries used.

If you change paradigm, you'll still have the boost of understanding logic (which from years of trying to teach is often taken for granted but is very rare among non programmers) if nothing else.

if (!inRange(truthyGrid[i].col, 0, x) || !inRange(truthyGrid[i].row, 0, 20)) {
....
}


Why do you not have such basic utility functions?

...

Since when are we in /sqg/?

simple programming questions are allowed in the daily programming thread

>too dumb to understand powerful abstraction
>conflates then with heaps of incidental brainlet-tier complexity

bump