[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 325
Thread images: 36

File: oop p2.png (57KB, 682x473px) Image search: [Google]
oop p2.png
57KB, 682x473px
Previous Thread: >>57369870

What are you working on, /g/?
>>
First for MODERN SEE PLUS PLUS
>>
>>57373855
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line;
procedure Cale is
type Days is (Sunday, Monday, Tuesday, Wednesday, THursday, Friday, Saturday);
type Months is (January, February, March, April, May, June, July, August, September, October, November, December);
type Date_Range is range 1..31;
package I_IO is new Ada.Text_IO.Integer_IO(Date_Range);

function Is_Leap_Year (Year : Natural) return Boolean is
begin
return (Year rem 4 = 0 and Year rem 100 /= 0) or Year rem 400 /= 0;
end Is_Leap_Year;

Day_Array : array (Months) of Date_Range := (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

Year_Input : Natural := Natural'Value(Ada.Command_Line.Argument(1));
First_Day : Days := Days'Value(Ada.Command_Line.Argument(2));

begin

if Is_Leap_Year(Year_Input) then
Day_Array(February) := Day_Array(February) + 1;
end if;

for I in Months loop
Put_Line(Months'Image(I));

for Enmpty in Monday..First_Day loop
Put(" ");
end loop;

for J in 1..Day_Array(I) loop
I_IO.Put(J, Width=>3);

if First_Day = Days'Last then
First_Day := Days'First;
else
First_Day := Days'Succ(First_Day);
end if;

if First_Day = Sunday then
New_Line(1);
end if;

end loop;

New_Line(1);
end loop;

end Cale;
>>
>>57374547
>C++ Without Classes
>>
>>57374547
NaN for JAVASCRYPT
>>
5th for python
>>
>>57374565
>Y
Appropriate.
>>
Is there high level dynamically typed language with easy interface to C?
Something where you can just use C libraries without having to define every used C type and function?
>>
>>57374594
Lua
>>
>>57374594
ASM
>>
>>57374594
Isn't python capable of doing that?
>>
>>57374594
Use MODERN SEE PLUS PLUS. Just template everything and use autos everywhere. It's dynamically typed, at compile time.
>>
>>57374594
Just use std::any everywhere and pretend it's dynamic typing.
>>
File: 1472967488631.gif (3MB, 343x400px) Image search: [Google]
1472967488631.gif
3MB, 343x400px
reminder the pajeet peoples fun levels are beyond the particle horizon
https://youtu.be/4TCnYYpZxEc?list=PL9F74AFA03AA06A11&t=2793
>>
File: 1454822354346.gif (999KB, 250x251px) Image search: [Google]
1454822354346.gif
999KB, 250x251px
Angular 2 or React for a front end javascript framework?
>>
>>57374783
why can't u just use html css and javascript to make a webshite
>>
>>57374783
Those are officially dead since, like, two weeks.
Everyone's using Vue.js now, where have you been?

You gotta keep up, man. Rewrite everything every month, that wheel's not gonna reinvent itself.
>>
>>57374805
Because all of these fucking job postings are asking for Angular or React skills
>>
>>57374805
>why can't u just use html to make a webshite
FTFY
>>
>>57374783
Both will give you cancer, so pick at random.
>>
>>57374826
Can vue.js be written using TypeScript?

Can I write a vue.js front end to gulp and npm and grunt so I can more quickly set up my vue.js dev environment?
>>
>>57374866
>vue
>gulp
>npm
>grunt
wew tech jargon retardation is getting out of hand.
>>
Is prototyping necessary in c++?
>>
remember that anime is illegal
>>
>>57374866
>Can I write a vue.js front end to gulp and npm and grunt so I can more quickly set up my vue.js dev environment?
Darling, that won't do. You need to use Webpack 2 and YARN or you can't call yourself a techie, understand?
>>
File: 1351041325464.gif (287KB, 340x335px) Image search: [Google]
1351041325464.gif
287KB, 340x335px
>>57374883
>>
File: 1476111082775.jpg (46KB, 540x652px) Image search: [Google]
1476111082775.jpg
46KB, 540x652px
>>57374914
brb deleting my files
>>
>>57374866
I know this is a joke, but, really, what's the best javascript stack to start with?
>>
>>57374987
jQuery.

t. SO contributor
>>
>hn discusses race and/or feminism
>>
>>57374987
Why do you even need a javascript stack. Just pick a good server-side language and use a minimal amount of client-side javascript for fuck's sake.
>>
File: MTE5NDg0MDU0NTIzODQwMDE1[1].jpg (140KB, 1200x1200px) Image search: [Google]
MTE5NDg0MDU0NTIzODQwMDE1[1].jpg
140KB, 1200x1200px
>>57375025
Again, because jobs.

Also using TypeScript with vue.js was a serious question but the other one wasn't :(
>>
which should i read first, design patterns or cracking the coding interview?
>>
Is there a way to edit the queue order in JS, instead of waiting for callbacks which by then it would already be too late?
>>
Hey /g/ I bet you can't find an algorithm to generate all permutations of 8 bits by only changing one bit at a time
>>
I've learned I hate my coworkers. People barely have more experience than I do yet they're the most stubborn assholes I've met, thinking their way is the only way to do something and that their seniority matters.
>>
>>57375104
Cracking the Coding Interview will make you think, DP is overrated.

>>57375110
Not without terrible hacks.

>>57375115
That's called reflected binary code.
>>
>>57374536

> tfw you can't get a binary number on a ti84

life is suffering

ti basic is a prison
>>
>>57375130
You sound just like them.
>>
File: nerd_sniping.png (101KB, 740x371px) Image search: [Google]
nerd_sniping.png
101KB, 740x371px
>>57375115
>>
Employed Haskell programmer reporting in
>>
>>57374594
Just use C# and the "dynamic" type.
>>
>>57375158
I realize that. It's a bit of my frustration coming through.

I've been pushing for more design discussions and attempts to nail down our actual spec (because we've had to rewrite classes multiple times due to missing large edge cases causing bad behavior) but it's hard when your coworkers can't explain why they're doing something a certain way and are not willing to budge an inch.

We have a couple of perfectionists who believe that their way is the only way to salvation, so we end up rewriting code according to one person and then having to rewrite it entirely later because either they changed their mind or someone else didn't like it.
>>
>>57375217
how often do you use comonads
>>
>>57375217
what do you do, generally? interested in learning it and want to see what people who work in it do.
>>
>>57375217
Good one.
>>
>>57375182
>Computer scientists = 1 point
>Pajeets = 0.0001
>>
Nice, they figured out how to add interfaces to Haskell. Should be simple enough.

http://plv.mpi-sws.org/backpack/backpack-paper.pdf

>reads paper
wtf?
>>
programming is boring, try to configure exim if you want a challenge
${sg{${lc:${domain:$h_from:}}}{^www\.}{}}
>>
>>57375239
Pajeet is very easily distracted?
>>
What's the most red pilled programming language?
>>
>>57375250
I'm quite mentally challenged as it is, thank you.
>>
>>57375281
assembly
>>
>>57375249
>what are type classes
>>
>>57375279
According to the comic it's easy to find a problem hard to solve for a Pajeet.

But you're right, unintelligent lifeforms won't try to compute a solution.
>>
>>57375249
>>57375308
Oh, that kind of interface. Never mind.
>>
File: bill-gates_lying.jpg (35KB, 390x312px) Image search: [Google]
bill-gates_lying.jpg
35KB, 390x312px
What is the runtimeof printSorteString?

int numChars = 26;
void printSortedStrings(int remaining) {
printSortedStrings(remaining, "");
}
void printSortedStrings(int remaining, String prefix) {
if (remaining == e) {
if (islnOrder(prefix) {
system.out.println(prefix);
}
} else {
for (int i = e; i < numChars ; i++) {
char c = ithLetter(i);
printSortedStrings(remaining - 1, prefix + c);
}
}

boolean islnOrder(String s) {
for (int i = 1; i < s . length(); i++) {
int prev
ithLetter(s.charAt(i - 1));
int curr = ithLetter(s.charAt(i));
if (prev > curr) {
return false;
}
}
return true;
}

char ithLetter(int i) {
return (char) ((int)'a') + i);
}


No cheating, you should be able to solve this.
>>
>>57375307
z80 or 6502?
>>
God damn vim is shit. The more I use it the more I think about switching to emacs.
>>
>>57375359
Sounds like a PEBKAC issue, it's the world's more powerful editor and everyone else uses it just fine.
>>
>>57375359
I love vim! why don't you like it?
>>
>>57375281
well can't you straight out write binary through an electric circuit?

that
>>
>>57375372
>Sounds like a PEBKAC issue
You don't even know what my issue is.
>the world's more powerful editor and everyone else uses it just fine.
It's not. Emacs is more extensible. Kakoune has bette vimgolf scores.

>>57375374
I'm currently fighting with the way the autocompletion popup menu behaves. I don't want to use YCM and AutoComplPop is kinda shit.
>>
>>57375359
What's wrong with a minimal GUI text editor?

Mousepad is pretty straightforward desu.
>>
>>57375401
So use emacs for a bit and see how you do. My only experience with emacs was harrowing, I had no idea what the fuck I was doing. I'm sure I could soldier through and become useful in it.
>>
>>57375401
>You don't even know what my issue is.
I don't need to, because vim is not "shit", it's actually a pretty damn good editor.
Chances are you're using it wrong.
>>
>>57375416
>What's wrong with a minimal GUI text editor?
It's inefficient. Switching back to a non-modal editor would make me want to kill myself.

>>57375431
>My only experience with emacs was harrowing, I had no idea what the fuck I was doing. I'm sure I could soldier through and become useful in it.
Same here. But I'm so used to vim that switching will be painful for months.

>>57375435
>I don't need to, because vim is not "shit", it's actually a pretty damn good editor.
Vim uses a good editing paradigm but is terrible otherwise. Vimscript is terrible. Its C code is terrible too. Its maintainer is a lazy fuck. Vim is shit and I say that as someone who's been using it daily for more than 6 years.
>>
>>57375526
>Vim uses a good editing paradigm but is terrible otherwise. Vimscript is terrible.
I completely disagree, I'll take vimscript over elisp)))) any day.

>Its C code is terrible too. Its maintainer is a lazy fuck
I'll give you that, though it looks like Neovim is lighting a bit of a fire under his ass.
>>
>>57375526
>It's inefficient
I disagree. I'll never understand codemonkeys... I basically spend more time thinking with a sheet of paper than programming.
>>
I'm converting a hex input given by the user and it outputs the value in decimal. It doesn't work and I don't know why.

 

unsigned long int hex2dec(const char *hex)
{
int sum = 0;
int v= 0;
int n=strlen(hex);
for (int i = 0; i<n; ++i)
{
if(i==n-1)
{
return sum;
}
if((hex[i] >= '0' && hex[i] <= '9'))
{
v = hex[i] - 0;
}
else
{
v = hex[i] - 'A' + 10;
}
sum += (v * pow(16, n-1-i));
}
}

>>
>>57375559
You just don't think fast enough.
>>
>>57375550
>I'll take vimscript over elisp))))
Do you have anything against elisp besides the parentheses?


>>57375559
>I basically spend more time thinking with a sheet of paper than programming.
The faster you'll edit your files the more time you'll be able to spend with a sheet of paper. That's exactly why I need to be able to code as fast as I can.
>>
>>57375603
If you don't need to think while programming then you're not doing anything useful.
>>
>>57375568
You're returning the value before finishing parsing it for starters
>>
I'm learning java at the moment.

How do I store a bunch of user inputted numbers in an array?
Currently I'm doing this:
public static double CalcAverage()   //create new method named CalcAverage
{
double dGradeCounter = 0; //initialize local variable GradeCounter
double dTotal = 0.0; //initialize local variable dTotal
double dGrade; //delcare local variable dGrade
double dAverage = 0; //initialize local variable dAverage
//dGrade = 100.0; Test
dGrade = Double.parseDouble(JOptionPane.showInputDialog("Please enter your grade or -1 to quit:")); //enter 1st numerical grade and parse as double

while (dGrade != -1) //-1 is the sentinel
{
dTotal = dTotal + dGrade; //total grade
dGradeCounter = dGradeCounter +1; //counter

dGrade = Double.parseDouble(JOptionPane.showInputDialog("Please enter your grade or -1 to quit:")); // continue entering grades
//dGrade= -1; Test
} //end of loop

//calculating average Grade
if (dGradeCounter != 0)
{
dAverage = dTotal / dGradeCounter; //calculate average grade
}
return dAverage; //return double dAverage.

>>
>>57375615
>Do you have anything against elisp besides the parentheses?
I have limited experience with it, but the API seemed really clumsy to me, and it looks like nobody anywhere gave a fuck about properly encapsulating things.
>>
>>57375634
I set the if statement to i==n, still doesn't work. :S
>>
>>57375668
Because you're looping for i<n, b-baka

return sum after the loop
>>
>>57375658
>but the API seemed really clumsy to me
More clumsy than Vim's? Man, it's like we live in two different universes.
Emacs's API seemed to make quite a lot of sense to me, but I don't a whole lot of experience with it either.
>and it looks like nobody anywhere gave a fuck about properly encapsulating
Yeah I kinda agree with you here.
>>
>>57375668

#include <stdio.h>
#include <math.h>

unsigned long int hex2dec(const char *hex)
{
int sum = 0;
int v, i= 0;
int n=strlen(hex);
for (i = 0; i<n; ++i)
{
if((hex[i] >= '0' && hex[i] <= '9'))
{
v = hex[i] - 0;
}
else
{
v = hex[i] - 'A' + 10;
}
sum += (v * pow(16, n-1-i));
}

return sum;
}

int main(){
printf("%d\n", hex2dec("FF"));
return 0;
}


This is what I mean, anon
>>
>>57375618
Who said anything about not needing to think?
Intelligent people just think faster than you can type.
>>
>>57374551
Also, here's the cleanest way I can think of to to the enumeration equivalent things.
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line;
procedure Cale is
type Days is (Sun, Mon, Tue, Wed, Thur, Fri, Sat, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday);
subtype Noramal_Day is Days range Sun..Sat;

type Months is (January, February, March, April, May, June, July, August, September, October, November, December);
type Date_Range is range 1..31;
package I_IO is new Ada.Text_IO.Integer_IO(Date_Range);
package Enum_IO is new Ada.Text_IO.Enumeration_IO(Noramal_Day);

function Is_Leap_Year (Year : Natural) return Boolean is
begin
return (Year rem 4 = 0 and Year rem 100 /= 0) or Year rem 400 /= 0;
end Is_Leap_Year;

Day_Array : array (Months) of Date_Range := (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

Year_Input : Natural := Natural'Value(Ada.Command_Line.Argument(1));
First_Day : Days := Days'Value(Ada.Command_Line.Argument(2));
Iterative_Day : Noramal_Day;
begin

Iterative_Day := Noramal_Day'Val(Days'Pos(First_Day) rem 7);

if Is_Leap_Year(Year_Input) then
Day_Array(February) := Day_Array(February) + 1;
end if;

for I in Months loop
Put_Line(Months'Image(I));
Put(" ");
for Day_Title in Noramal_Day loop
Enum_IO.Put(Day_Title, Width=>6);
end loop;
New_Line(1);

for Enmpty in Mon..Iterative_Day loop
Put(" ");
end loop;

for J in 1..Day_Array(I) loop
I_IO.Put(J, Width=>6);

Iterative_Day := (if Iterative_Day = Noramal_Day'Last then Noramal_Day'First else Noramal_Day'Succ(Iterative_Day));

if Iterative_Day = Noramal_Day'First then
New_Line(1);
end if;

end loop;
New_Line(1);

end loop;

end Cale;
>>
Now that I learned about complexity analysis I can't stop trying to find more efficient way to do my programs. It's driving me nuts.
>>
>>57375794
don't forget those hidden constants anon
>>
What language should i try out to start with basic programming and please no python because i hate that language.
>>
>>57375763
That doesn't seem "clean", seems like a hack, especially if all you want is for the user to be able to input "Sun" and Get returning Sunday. Sounds more like you should just implement a Get function.
>>
>>57375932
C. If you give up when you reach pointers try Javascript.
>>
>>57375794
Just wait until you learn about cache.
>>
>>57375932
Start with c
>>
>>57374783
Just simulate MVVM with reactive streams.
>>
>>57374536
whats uint8_t
>>
>>57375932
visual basic
>>
>>57375932
Well for a beginner it's mroe about learning how to abstract logic unto the computer. THe language is just a means to an end.
>>
>>57375932
why do you hate it?

Ultimately you will learn that a language is a tool; you use the best tool for whatever you have to do. Python is the best one if you want to learn programming concepts.

Every OOP is shit anyways so try Haskell if you want to be a smartie.
>>
>>57375961
THIS

Try to stay away from an OO language because any learning resource related to that language will mostly focus on masturbating to classes and design patterns without actually getting anything done.
>>
>>57375936
It's not that bad. The proper way would be more complicated, taking in a string and comparing them the two different enumerations and then returning the main enumeration you want to use.
>>
>>57374547
D deprecates C++ for the majority of use cases.
>>
>>57376024
why?
>>
Please help. What am I doing wrong here?
I'm trying to get the average of the values in the array.
        double dTotal = 0;
double dAverage = 0;
double[] dGrades = new double[10];
for (int i = 0; i < dGrades.length; i++)
{
dGrades[i] = Double.parseDouble(JOptionPane.showInputDialog("Enter your grades"));
dTotal = dTotal + dGrades[i];
dAverage = dTotal /dGrades.length;
}
return dAverage;
>>
>>57374536
I'm making my own programming language.

I have the parser taking my language fine, and I am using LLVM for the backend, which I already have set up.

The problem that I have, is I have no idea how exactly am I going to do semantic analysis.

The more I read into it, the more abstract it becomes with no simple implementations in sight. I saw one on github that was supposed to be a "simple" typechecker. Contained more LOC than the rest of my entire project.
>>
>>57376059
Seems ok to me although a bit inefficient (the division should happen after the loop is done).
What's the issue?
>>
>>57376021
>not that bad
>enumeration with more values that it actually is supposed to represent just to kludge user input
its pretty bad

>taking in a string and comparing them the two different enumerations
It should just be something like
if UserInput = "Sun" or UserInput = "Sunday" then
return Sunday;
end if;

and not having Sun and Sunday being different values. Tying user input to source code symbols isn't usually that great anyway, and then you further break the idea by needing to introduce that modulo to get the "real" value
>>
>>57376059
I haven't written any Java in a long-time.

But debug it like this:
Is the return value of your input correct?
Does dGrades.length do what you think it does?
>>
File: vfxnag.png (49KB, 723x622px) Image search: [Google]
vfxnag.png
49KB, 723x622px
Got tired of the nag screen in VFX Forth free version so I decided to have a go at patching it out.
There isn't any checking for a valid license or anything, the evaluation version is just a different binary so a hackish nop fill of the nagging is all you could do.
nop out the Sleep and DialogBox calls from 100019B3 to 100019D7 in vfxsupp.dll.
>>
>>57376144

I should start doing that with some of the freeware I use.

Might be fun.
>>
File: 1475948969651.jpg (1MB, 1904x4706px) Image search: [Google]
1475948969651.jpg
1MB, 1904x4706px
>>57375932
scheme

why the fuck did the educational system drop scheme? these fresh grads get dumber by the year
>>
File: 1464905846565.png (275KB, 387x299px) Image search: [Google]
1464905846565.png
275KB, 387x299px
>>57374536
How much time do you spend per day learning a new programming language?
>>
>>57376059
Do the division for average after the loop.
>>
>>57376194
I already know all of them
based documents

you should be asking how much time do you spend on coming up with new algorithms per year
>>
>>57376201
>>57376087
Thank you.
>>
>>57376201
>>57376224

Why would it matter regarding the final calculated value? He always overwrites the previous value.

Although it might be that length gives back 9 instead of 10 aka the last index. I haven't programmed in Java in a long time.
>>
>>57376194
I prefer focusing on getting proficient with one language instead of halfassing new languages.
>>
>>57376214
doesn't it take time to initially memorize the concepts while writing those algorithms?
>>
>>57376237
>>57376224
Nevermind, I'm retarded. That way works, I don't even see what the problem was. I ran it and it worked as intended.
>>
>>57376244
ok so how long do you spend per day getting proficient with that one language?
>>
>>57376194
3 minutes
main language 4 minutes
>>
File: 1466654536872.jpg (3KB, 100x125px) Image search: [Google]
1466654536872.jpg
3KB, 100x125px
>>57376275
Is this bait?
>>
> tfw constantly have to correct my teachers code in class
How do I handle the feel of everyone staring at me
>>
File: 2038u083.jpg (21KB, 235x244px) Image search: [Google]
2038u083.jpg
21KB, 235x244px
>tfw you want to write good code but JavaScript won't let you
>>
>>57376296
yeah and now im getting paid 2000/mo
>>
>>57376299

Quit being such an annoying little fag.
>>
>>57376309
The fuck do I do when the teacher spends 5 minutes looking at compiler messages then
>>
>>57376299
Everyone makes coding errors. No one thinks you're smart. Just because the teacher doesn't notice a missing bracket as they type doesn't mean you're an intellectual for catching it.
>>
>>57376318
browse 4chan and stop being a bitch
>>
>>57376309
this
>>
>>57376318

Sit there quietly and contemplate life like everybody else.
>>
>>57376309
Well said. I'm unfiltering you.
>>
>>57376328
>Implying there is anything valuable in life
>>
>>57376299
how big are these "errors"
>>
>>57376348
I live for the sake of jacking off
>>
>>57376328
I already know my life has no purpose

>>57376321
It's not just coding errors. If it's something like a missing semi colon, I can understand. This Bitch gets basic concepts wrong
>>
>>57376063
I would suggest familiarizing yourself with the simply-typed lambda calculus. You'll learn about basic stuff like term/type syntax, judgements, contexts, inference rules, reduction, etc. which are all important to any kind of type checking.

For instance, consider the (single-parameter) simple function type A -> B, where A and B are types. This is expressed by the type rule:
G |- A type   G |- B type
-------------------------
G |- A -> B type

You then have functions themselves:
G |- a : A   G, a : A |- b : B
------------------------------
G |- λa.b : A -> B

This rule means that a lambda expression λa.b has the type A -> B if a has the type A and b, a term where a variable a is bound with the type A, has the type B.

The type checking algorithm, given a term λa.b, would first check that the type given is of the form A -> B. It would then extend the context with a variable a with the type A, and check that the term b has the type B recursively.

This is all rather straightforward to do with a functional language like Haskell or ML, but it gets tricky without algebraic data types and pattern matching.
data Term = Variable String | Lambda String Term | ...
data Type = Arrow Type Type | ... deriving Eq

type Context = String -> Type
extend :: String -> Type -> Context -> Context
extend x a g y
| x == y = a
| otherwise = g x

check :: Context -> Term -> Type -> Bool
check g (Variable x) a = g x == a
check g (Lambda x t) (Arrow a b) = check (extend x a g) t b
check g (Lambda _ _) _ = False
check ...
>>
>>57376307
That's chump change
>>
>>57376374
For example, she didn't realize that once a variable leaves a scope it was defined in, i.e. a for loop, that you can't access it anymore
>>
>>57376385
Could you give an example of what you consider a wrong basic concept?
>>
>>57376385

If I was you, I would take a teachers incompetency personally
>>
>>57376063
>>57376391
Essentially, the term/type syntax and inference rules translate directly to your AST and type checking algorithm.
>>
>>57376407
>>57376403
>>
What game should I buy on steam?
>>
>>57376194
I study 1-3 languages/frameworks/technologies at once, only about 15 minutes per day on each language/framework/technology. I find that it is difficult to absorb more information about a language after 15 minutes of study, i.e., I stop taking information after 15 minutes of focus. Then I try to immediately apply what I learned in the language/framework/technology in some small project or exercise. The point I've found is to have some part of your mind which at one point knew something, even though you may forget the specifics, so that you can recognize it as a solution to some problem in the future. The second time you learn it, after recognizing it is fitting for a solution to some problem, it is cemented in your mind. This works for functions, syntax, patterns, techniques, whatever. Whereas if you fly through a book, you don't get the depth on each individual feature, and you end up having to re-learn the same thing ten times. Even when I want to fly through a book, I go section by section every day, which means each new book takes about a month. A book in this case would be a classic text under 400 pages. Anything over 400 pages is a reference and shouldn't be studied using this technique.
>>
>>57376109
That's essentially no different than what I did, since the main enumeration is just for user input and the subtype is for actual use.
>>
>>57376439
>TIL there are non autistic people on /g/ that need to learn programming
>>
>>57376403
so what exactly did you tell her when correcting it?
>>
>>57376391
Just realized that second rule is weird.
G, a : A |- b : B
------------------
G |- λa.b : A -> B
>>
>>57376332

Thanks, I appreciate it.

>>57376348
>>57376385

I agree, but there's still plenty worth contemplating.
>>
>>57376463
Autists are language jocks. Software engineering is an art form.
>>
>>57376469
I don't remember the exact code, but something like
for(int a=0; a<10; a++)
{
//code
}
cout << a << endl;

To
int a;
for(a=0; a<10; a++)
{
//code
}
cout << a << endl;
>>
File: esolang.png (41KB, 620x343px) Image search: [Google]
esolang.png
41KB, 620x343px
/dpt/ I want to create an esoteric programming language. Give me an idea.
>>
>>57376542

emojilang
>>
>>57376304
Write in Parenscript then.
>>
>>57376534
what a rookie mistake, even i could tell you that and ive just done youtube tutorials at this point
>>
>>57376559
I thought about doing that but it turns out it was already a thing:
http://www.emojicode.org/
https://github.com/4Lang/4

Doesn't mean I can't implement my own but I'd kinda like something more novel.
>>
>>57376439
An insightful post. I also feel overwhelmed if I exceed a small time frame. Imo this is why most people flunk classes. Not enough time to truly absorb the concept.
>>
>>57376263
4 hours
>>
implementing a hashmap why the hell am i getting -1 for index?
 int index = key.hashCode() % values.length; 
>>
>>57376672
Is hashCode a signed int?
It's not guaranteed not to be negative, just unique.
>>
>>57376631
better idea:
implement some kind of shitty psuedo onion routing using dns or icmp tunnels.
>>
>>57376672
The hash code can be negative, and negative numbers give negative remainders.

Math.abs(key.hashCode()) % values.length
is a common but incorrect workaround.
Math.abs(key.hashCode() % values.length)
is mostly ok.

>>57376685
It's not guaranteed to be unique, it's only guaranteed (by unenforced contract) to be equal when the objects are .equals().

In particular, it's not guaranteed to be different if the objects are different.
int hashCode() { return 42; }
is a 100% valid and correct implementation.
>>
Ok so A-F works, but 0-9 doesn't. No idea why.

unsigned long int hex2dec(const char *hex)
{
int sum = 0;
int v= 0;
int n=strlen(hex);
for (int i = 0; i<n; ++i)
{
if(((hex[i] >= '0') && (hex[i] <= '9')))
{
v = hex[i] - 0;
}
else
{
v = hex[i] - 'A' + 10;
}
sum += (v * pow(16, n-1-i));
}
return sum;
}


>>
>>57376745
Thanks for that! Very helpful.
>>
>>57376754
v = hex[i] - 0;

You're subtracting 0, not '0'
>>
>>57376764
why is that?
>>
>>57376813
Not anon posting the solution but I believe the 0 in single quotes is a different value than the 0 without
>>
>>57376813
0 is 0
'0' is 48
>>
>>57376754
You're also not checking correctly if the "else" is within 'A' and 'F' or 'a' and 'f'.

try:
if(hex[i] >= '0' && hex[i] <= '9')
{
v = hex[i] - '0';
}
else if(hex[i] >= 'A' && hex[i] <= 'F')
{
v = hex[i] - 'A' + 10;
}
else if(hex[i] >= 'a' && hex[i] <= 'f')
{
v = hex[i] - 'a' + 10;
}


Also, don't use pow when you can shift!
Luckily as 16 is a power of 2, you can emulate the pow by shifting by 4 (because 2^4 = 16) plus n-i (I believe)
sum += v << (4*(n-i));
>>
>>57376889
>>57376834
I see, thanks guys.
>>
>>57374594
python
>>
>>57374551
>>57375763
>>57376109
Good to see a REAL language being discussed here. Keep up the good work, soldiers.
>>
i'm gonna learn C as my first language. wish me luck
>>
>>57376754
>>
>>57377094
what color scheme you editor
>>
File: dsvds.png (77KB, 395x290px) Image search: [Google]
dsvds.png
77KB, 395x290px
What language should I learn that's fun and won't make me cry? I know the basics of a couple of languages but they made me cry when I tried to go deeper.
I'm not good at researching things myself so I rely on strange men on the internet that I view as Gods
>>
>>57377192
jellybeans
>>
>>57377210
>What language should I learn that's fun and won't make me cry?
There is no such language. The fact that anything could make you cry proves you're a subhuman who cannot program.
>>
>>57377210

Considering that multiple languages have made you cry as you try to get into the 'deeper stuff', you may just not be very good at programming.
>>
>>57377210
>What language should I learn that's fun and won't make me cry?
All of the common and interesting ones
>I'm not good at researching things myself
Work on that first. It's a more important skill than programming.
>I rely on strange men on the internet that I view as Gods
Kill yourself
>>
>>57377234
Qt has made me cry. Or rather, trying to get Qt to work with Visual Studio.
>>
>>57377210
SICP
>>
>>57377234
>>57377244
>>57377248
bullies fuck off!
>>
>>57377210
>I know the basics of a couple of languages but they made me cry when I tried to go deeper.
but that's the fun part. You won't have fun unless you're doing the fun stuff which is the stuff deep in the languages.
>>
Does anyone have that pictures that lists all of the C languages?
>>
mods are asleep post forbidden secret C techniques
>>
>>57377230
WONDERFUL?!
>>
File: tegaki.png (3KB, 400x400px) Image search: [Google]
tegaki.png
3KB, 400x400px
>>57377301
>>
File: List of C Languages.png (17KB, 418x311px) Image search: [Google]
List of C Languages.png
17KB, 418x311px
>>57377301
>>
>>57377301
how is they gonna fit to one picture my nigga
you is crazy
>>
>>57377358
>serif
>>
>>57377383
CMU Serif to be precise
>>
>>57375638
Use a List if you don't know the amount of grades.

ArrayList<Double> grades = new ArrayList<Double>();

grades.add(cocks);
>>
>>57377383
>sans serif
you plebian
>>
>>57377283
I doubt anyone has actually read that lol
>>
>>57374536
What's the best way to learn C?
>>
>>57377692
reading book and doing HW/project asignments that top univiersities use if they have them online
>>
>C++
I'm waiting for an input from the terminal. The user is writing in a buffer where he can backspace etc.
Any idea how could I pre-fill that buffer?
So the user may use the pre-filled value, or backspace it and write something else.

I suppose it relies on the stl, std::cin etc. On the bus right now, will check when I arrive at home.
>>
>>57377272

Try not using Visual Studio. You'll be fine.
>>
>>57377091

>Join the Navy
I've checked on usajobs.gov, and the DoD does not appear to be hiring programmers in my state. A damn shame.
>>
Hey /dpt/, could you help me out?

Pic related is my own compiler's parser's output and the source code it's reading. I know my toy C-like language grammar is slightly weird, but...anyway.

I'm testing my parser. It's written in C, and as much as I used valgrind and profiled the shit out of it, that doesn't protect me against potential mistakes I've made, ones that don't surface in my limited testing scope.

So I'm asking you this: could you write some bullshit C-looking code that I can use to test? Doesn't have to be a lot. Simple language constructs are sufficient (pointers aren't a thing that i'm going after), so function calls, math, loops...

Things that don't work:
1) else statements. I forgot to reserve the token when I was first writing my lexer, and didn't want to distract myself when the mistake came up later on
2) ++ and -- don't exist. Use += 1 and -= 1. Low priority but will fix.
3) Any kind of analysis. So far, this only checks if the code's grammar is valid, not even whether variables were declared etc.
>>
/dpt/ newbie here, I have been working with a C file, but I need to compile it as a C++ file

Anyway to do that on codeblocks? I try to change the environment to compile to C++ but it swaps back to GCC/C compiler automatically.

Should I just create a new project as C++ as paste the code there?
>>
>Get a perl script to strip youtube video titles and links and then forward them to MPV when one is chosen in about 35 lines
>Can't install Curses package because CPAN is shitting the bed
God fucking damn it
I just want to never have to expose my browser to that website again. Is that so much to ask?
>>
>>57378581

g++ -std=c++14 whatever.c
>>
>>57375115
https://en.wikipedia.org/wiki/Gray_code
>>
>>57378631
He asked for codeblocks.
>>
File: sad-pepe-640x480.jpg (29KB, 640x480px) Image search: [Google]
sad-pepe-640x480.jpg
29KB, 640x480px
>>57374536
I feel like I'm losing it. I'm in my last year, and I just hate studying. I want to start working and move out so bad. The coding is good, but I am so sick of theory and being a poorfag student who lives with his mommie and daddie. I am never, ever going to fucking use it, and if I do I will just look it up when I need it. I have never retained any specific thing I have learned in university for longer than a year, and I usually forget 80% of it after 6 months.
>>
>>57375658
>>57375704
Reminder that namespaces are a mistake and elisp is your savior.
>>
>>57378668
Well wtf can you code something?

Like surely it's taught you something and challeneged your mind enough to when you actually sit down to write something useful, well you'll have the competency in solving the probl.m
>>
File: 1454782361171.png (16KB, 259x224px) Image search: [Google]
1454782361171.png
16KB, 259x224px
Here's my shitty python script.
http://pastebin.com/wd1Q6kFC

It's a script to bulk rename all files in a folder. It works but if the script find a file with the same name format from my input the script deletes it.
Can someone explain why and how should I fix it?
>>
>>57378698
Real coding is working with libraries and frameworks, not reinventing the fucking wheel for marks on a piece of paper. Fuck uni.
>>
>>57377533
Your new is showing. Lurk moar.
>>
>>57377911
You can't pre-fill the tty driver's input buffer.

You'd need to put the terminal into raw mode and handle individual key presses (including backspace) yourself.

The readline library (which does a similar thing but with a lot more editing functionality) will probably let you pre-fill the buffer. However, note that readline is GPL (not LGPL).
>>
>>57378668
>I have never retained any specific thing I have learned in university for longer than a year, and I usually forget 80% of it after 6 months.

I always thought this was just me. It kind of blows me away when people remember random convergence theorems from calc 2 and shit
>>
>>57377533
Holy shit
>>
>>57378728
It makes the whole experience seem pointless. There is a lot of shit that is not prerequisite to other shit in the 4 years you spend in uni, and you forget almost all of it.
>>
>>57378646

And I gave him a better tool.
>>
>>57378668
> I am so sick of theory
> I am never, ever going to fucking use it, and if I do I will just look it up when I need it

It doesn't work like that. If you don't have even a passing knowledge of the theory, you won't even realise that there's some theory out there which deals with your problem so you won't know that you should be looking anything up.

>>57378710
> not reinventing the fucking wheel
Not every programming job is pajeet-tier unskilled labour where every problem you will ever encounter has already been solved for you. And most of the ones which are have either already been outsourced or will be in the near future.
>>
>>57378571
Anyone? Help a fellow C programmer out, anons
>>
>>57378814
>If you don't have even a passing knowledge of the theory

Nobody said I wouldn't have a passing knowledge of theory. This is year 4. They've pretty much finished teaching me basic shit about algorithms and trees. Now it's all make work projects.

Don't forget to kys.
>>
>>57378846
>Don't forget to kys.

ur mad lol
>>
File: punching canadian frog.png (100KB, 785x757px) Image search: [Google]
punching canadian frog.png
100KB, 785x757px
>>57378855

Say my name tripfag.
>>
>>57378560
Aren't you in Switzerland or some Custardly country?
>>
>>57377433
Neat, thanks.
>>
>>57378870

a fucking leaf
>>
>>57377210
Why would you want to learn the basics again? Once you know the basics of one you know them all, unless you're going into FP, in which case the basics will make someone like you cry too.
>>
Reminder that somebody loves you!

http://heart.pai.ontopcorp.com/
>>
>>57374783
React. Angular 2 is going to kill the Angular project. If you want to find legacy legacy work learn Angular 1.4 or 1.5.
>>
>>57376299
Everyone's staring at you because you're going to be curving the grade and they all know lmfao.
>>
>>57379015
How can someone love me if I don't even love myself
>>
>>57379015
thanks anon I love you too
>>
File: 1477836894134.png (194KB, 498x430px) Image search: [Google]
1477836894134.png
194KB, 498x430px
>>57378668
>mfw good at programming but too poor for university, while everybody else is living comfy uni life cobbling together lamo JS webshit, I am working 12 hour days moving heavy marble slabs and spending the weekends writing full-fledged applications in C
I'm so bitter.
>>
>>57378874

Nope. Born and raised in Washington state.

>>57379262

>too poor for university
Fucking FAFSA, dumbass.
>>
>>57379262
42.us.org
>>
>>57379311
State schools are cheap as fuck too, there's practically no excuse. Community colleges are even cheaper
>>
>>57379311
Damn, dude. You're a fucking cunt. Did you fuck a Canadian recently or something?
>>
I'm writing a simple object to parse a configuration file for my GUI program. It's not the type of program that is going to be running as a daemon or for a long time. It would be marginally easier to write my program to open the file for writing the entire time the object exists (and this the application is loaded), and then close it in the destructor as I'm following C++ RAII programming. It also means less PEBKAC could occur. Should I do that, or is it better practise to simply open the file stream and close it when needed? Each member function is a run > do something > return, and they don't all need to write, sometimes only read, which is probably a good argument for that way too.
>>
>>57379390
>and this the application is loaded
thus while*
>>
why do people dislike oop? I've just started learning c++
>>
File: 1478114657081.png (299KB, 680x598px) Image search: [Google]
1478114657081.png
299KB, 680x598px
>>57379262
>mfw too intelligent to bother getting a job
>>
>>57379311
Yeah I filled it out, I can get like $5k in grant money.
Still, that's enough to get stabbed at community college.
I couldn't even go if I had the money, the logistics just aren't there.
My shits all sorts of fucked up, I can't even keep a sleep schedule. Fuck me.
>>
>>57379502
>tfw getting too intelligent and want to stop working for life
neet is the smart move
>>
File: fuggedupcode.jpg (28KB, 761x205px) Image search: [Google]
fuggedupcode.jpg
28KB, 761x205px
>>57374536
Hey guys I'm trying to make a calculator program but its extremely buggy

Everything works if you input them properly
>like 6 + 6 = 12

but if you fuck around like pic related all kinds of funky shit happens

if any of you guys could help me find the problem it would be really appreciated

I'll reply with my code, shits too long
>>
Hey guys. You probably don't care, but I made a discord server for programming talk. Join if you want.

https://discord.gg/ZNjjDps
>>
>>57379632

I left out the scanner, class name, and the ending brackets because apparently the shit takes up too much space

double firstNumb = 0;
double secondNumb = 0;
double result;
char operation;

while (true)
{

{

System.out.println("Enter your calculation: ");

if (in.hasNextDouble())
firstNumb = in.nextDouble();
else
System.out.println("Error! Please use the proper formatting!");

operation = in.next().charAt(0);

if (in.hasNextInt())
secondNumb = in.nextDouble();

else
System.out.println("Error! Please use the proper formatting!");


switch(operation)
{
case '+':
result = firstNumb + secondNumb;
System.out.println(firstNumb + " + " + secondNumb + "=" + result);
break;

case '-':
result = firstNumb - secondNumb;
System.out.println(result);
break;
case '*':
result = firstNumb * secondNumb;
System.out.println(result);
break;
case '/':
if (secondNumb == 0)
{
System.out.println("Error! Cannot divide by 0, for this is: ");
}
result = firstNumb / secondNumb;
System.out.println(result);
break;
case '%':
result = firstNumb % secondNumb;
System.out.println(result);
break;
>>
What is this shit called that gets put into webpages instead of some punctuation?
like &#39; is put in instead of '
what's that encoding called? I need a simple way to revert it back to normal text but I can't remember the encoding type
>>
File: 1473828198812.jpg (60KB, 313x377px) Image search: [Google]
1473828198812.jpg
60KB, 313x377px
>tfw used break in a code
>despite being taught by all my professors to never, EVER use it

now I feel awful
what kind of punishment do I deserve? I want to cleanse my body for such sinful and disrespectful act against my superiors
>>
>>57379644
>firstNumb
>Numb
You anger me.

Also Java handles long numbers kinda stupid. Do a try/catch around setting BigInteger firstNum = BigInteger.Parse(in.nextLine().trim()); and throw an exception if it's improperly formatted
>>
>>57379670
What kind of retarded-ass professors teach students to "never EVER use" break?
>>
File: 1477270339038.png (692KB, 963x720px) Image search: [Google]
1477270339038.png
692KB, 963x720px
>>57379670
>despite being taught by all my professors to never, EVER use it
That's because they're very isolated from reality.
In theory, you shouldn't ever need to use a function break. It's short-circuiting and "ideal" code shouldn't do that.
But that's a stupid thing to try and accomplish in real code.
>>
>>57379692

the good ones
>>
>>57376534
To be fair, declaring variables in the for argument parameters was added later to the standard, and one would expect it ot just be syntactic suggar instead of altering the working of the language.
C is a mess of features, so dunno.
>>
>>57376299
As long as you're pointing mistakes out in a "wouldn't that blah blah blah?" in order to skip the part where they get confused that their shit isnt working and waste 5 minutes fixing it, then nothing.
If people are staring at you then you're probably doing it like an asshole
>>
>>57379506

Subsidized loans. Take those too. If you think a degree will get you a job, the loans will be worth it. Otherwise... just work on a portfolio.

Oh, also, scholarships. Get them if you can.
>>
>>57379681
first time learning this shit pls be kind :^(

I havent learned try/catch but im looking it up now thanks m8
>>
>>57379657
Numerical character reference. The number is the unicode code point, and may be in decimal or (if preceded by "x") hexadecimal.
>>
What's the best case runtime for checking whether a trie contains a particular string?
>>
>>57379506
It's probably 5k a semester. That's enough for state school tuition with money left for books.
Also, community college aren't crime ridden cess pools, which is what u seem to think is the case.

If you want that degree you'll get it, no matter what's in your way. You must not want it.
>>
>>57379681
I'm not understanding I've been trying and I can't get it to work

I'm a total beginner if you could help me out that would be amazing m8
>>
>>57379841
I'd assume O(n) with n being the length of the string.
For an actual time number it depends on if the data is cached or not, the speed of access, etc.
>>
i want to post a blog post to help some beginners understand the use of git add -p and i wrote my draft in markdown, what do you all look for in programming articles?

i was thinking about just rolling it out a github page since it's just static text, but what do you guys think
>>
>>57379862
You see how when you put in 888888888888888 it prints back out an error with 8.8888888E11?
It's an issue with the float data type.
You could maybe store the next input as a string, check it's length, and determine what to store it as from that.

Also, your second number is being checked for ints and stored as double. You should make it match the first input for consistency.
>>
>>57379871
wouldn't it be O(1) in the case that the string might be the prefix of a much longer string? or if it's an empty string or an empty trie?
>>
>>57379896
I assumed you were doing per character.
Sure if you got a thing that has the entire string as key/prefix it would be O(1)
>>
File: 1474517601111.jpg (246KB, 1417x1260px) Image search: [Google]
1474517601111.jpg
246KB, 1417x1260px
>>57379881
holy fuck I actually got it to work doing the try/catch thanks so much man

     while (true)
{

try
{

System.out.println("Enter your calculation: ");

firstNumb = in.nextDouble();

operation = in.next().charAt(0);

secondNumb = in.nextDouble();



}
catch(Exception e)
{
System.out.println("Error: improper formatting detected");
break;
}


Now if you try to throw in a fuck huge number, after the second input you get the error. I guess the program is still storing huge numbers for some odd reason.

and thanks for pointing out the int, I didn't even notice that.

kek bless you
>>
File: 1474757199103.jpg (116KB, 1280x720px) Image search: [Google]
1474757199103.jpg
116KB, 1280x720px
>>57379968
The best part is I was talking completely out of my ass
I have absolutely no idea why your floats were turning into scientific notation
>>
>>57378668
you're almost done, just get C's in your last quarter and get a job. Working isn't that much like college and anything you can learn in 2 weeks for a class you can pick back up again in a few days while in an office.

Start preparing for interviews, it will be fine.
>>
>>57379968
fix your FUCKING SPACES
>>
>>57379968
its probably because I left out the
if (in.hasNextDouble()) but idk lel

>>57379979
top fukken kek

>>57379984
I will, the reason why they are so fucked is because ive been trying out different shit
>>
>>57379262
>tfw hs dropout and would have to do a year of more education just to get grades good enough to apply to uni
>>
>>57379262
Just fight your way into any IT position and spend all day writing programs and scripts.
the last job I had one of our three senior devs was only 20 and had 0 formal education, but he knew his shit incredibly well and was good at it. Degrees don't go as far as you'd think in CS. Especially now that they water them down to just LEARN TO ALGORITHM LOL
>>
File: 1474513455593.jpg (50KB, 552x615px) Image search: [Google]
1474513455593.jpg
50KB, 552x615px
>>57379979
I figured it out, if (in.hasNextDouble()) was doing it

what in the actual fuck lmao
>>
>>57380035
Are you implicitly casting a double to a float?
>>
File: 1474646102802.gif (2MB, 286x400px) Image search: [Google]
1474646102802.gif
2MB, 286x400px
>>57380042
it sort of worked for error testing to see if what the user was putting in was actually something like 2 + 2 and not "nigger"

the problem was that if you put in huge numbers and a ton of random characters it didn't work anymore
>>
>>57380082
Float isn't as big and is dropping your double down to scientific notation. Large penis into small vagina, some tearing is gonna be inevitable but it'll sort of work.
>>
>>57379979
Because most print function would rather print
3*10^240
Than an unreadable number with 240 digits.
Not sure what the actual threshold is.
>>
>>57378668
Stop complaining and just do it.
You guys have it easy, Software Engineering takes a minimum of 7 years in my college, the average graduation is 9 years. Naval engineers are said to take 13 years on average.
At least it's free.
>>
>>57380101
At last I truly see
>>
>>57380133
>military bullshit

Lol.
>>
>>57380178
Wrong.
>>
>>57380182
Where the fuck do they teach "naval engineering" then" What country are you in where it takes 7 years to do SENG?
>>
>>57380200
To be fair, engineering degrees here are equivalent to bach+masters of the US. The official program is just 6 years, but it's impossible to do in that time due to bad scheduling and general bullshit.
>>
>>57380007
>tfw too intelligent to bother about good grades
>>
File: php.jpg (10KB, 211x87px) Image search: [Google]
php.jpg
10KB, 211x87px
Why doesn't it echo "7 + 3 = 10"?
It only echoes "10".
>>
>>57380812
h-help
>>
>>57381034
Does this work?

echo $x . " + " . $y . " = " . $x+$y;
>>
>>57381160
Nope. Also gives 10.
>>
>>57380812
This works:
```
php > echo "$x + $y = " . ($x+$y);
7 + 3 = 10
```
>>
>>57380812
the joys of weak typing

I'm guessing you end up adding $y to a string, that gets converted to 3
>>
>>57381205
>Using markdown on an imageboard
>>
In a programming language of your choice: write a program that checks if two strings are "vowel equal", e.g. vowelEq("hello", "derpo") == true
>>
>>57375115
you can just walk through an 8-dimensional k-map for that.
>>
What is the best option of using lstat and S_ISLNK on winlel? (mingw)
>>
>>57381297
tidied up the formatting

vowels = "aeiou"
vowelEq [] [] = True
vowelEq (x:xs) (y:ys) | x == y = vowelEq xs ys
| otherwise = and [x `notElem` vowels,
y `notElem` vowels,
vowelEq xs ys]
vowelEq _ _ = False
>>
>>57381205
Thanks a bunch!
>>
>>57381297
vowelEq = lambda a, b: reduce(lambda x,y: x and y, (x == y if x in 'aeiou' else True for x,y in zip(a, b)), True)
>>
>>57381393
check "hello", "hell"
>>
>>57381297
#include <ctype.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>

bool vowel_equal(const char *s1, const char *s2)
{
static const bool vowels[UCHAR_MAX] = {
['a'] = true,
['e'] = true,
['i'] = true,
['o'] = true,
['u'] = true,
};

while (*s1 || *s2) {
if (vowels[tolower(*s1)] ^ vowels[tolower(*s2)])
return false;

if (*s1)
++s1;
if (*s2)
++s2;
}

return true;
}

int main(int argc, char *argv[])
{
if (argc != 3) {
fprintf(stderr, "usage: %s string-1 string-2\n", argv[0]);
return 1;
}

puts(vowel_equal(argv[1], argv[2]) ? "Matches" : "Does not Match");
}


Your question is underspecified. It doesn't say what should happen if the strings are different lengths, and the longer string contains a vowel near the end.
My program will "match" if it does not contain a vowel, and will not "match" if it does.
>>
>>57374883
javascript ecosystem is fucking attrocious for this, half a dozen different things for doing every task and they all have their own quirks.

sometimes I (nominally C++ and bash back end dev, original dev for our angular frontend though) have to help our dedicated web dev with harder tasks and it really fucks me off to have to learn about gulp and npm and node and angular and all that retarded shit over again.
>>
>>57381423
now you ruined my one-liner:
from itertools import izip_longest
vowelEq = lambda a, b: reduce(lambda x,y: x and y, (x == y if x in 'aeiou' else y not in 'aeiou' for x,y in izip_longest(a, b, fillvalue='b')), True)


(yes, I konw about __import__ but that's cheating)
>>
I'm recoding printf, any tips on how I should implement it?
>>
>>57381467
run echo in the shell
>>
>>57381467
>I'm recoding printf
Are you writing just a simple formatter, or are you going to actually implement all of the different printf flags and features?
>>
>>57381474
Yea, I'm actually trying to reimplement all the flags and features. I did some work already, but I want I'm not sure about the general direction my code should take. I start by getting all the differents flags in a structure and then using a array of pointer to functions to call the right function. It's pretty spaghetti I feel.
>>
Select all images with a bus.
>>57381297
import Data.Function
vowelEq = on (==) $ filter $ flip elem "aeiou"
>>
>>57381492
printf is a pretty complicated function. It's probably going to kind of messy, no matter how you do it.
>>
>>57381511
Doesn't work
>>
>>57381553
elaborate
>>
>>57374594

In Ruby it's super easy to use C.

require 'inline'

class InlineTest
inline do |builder|
builder.include '<math.h>'
builder.c '
int inline_pow(int a, int n) {
return pow(a, n);
}'
builder.c '
long inline_factorial(int max) {
int i=max, result=1;
while (i >= 2) { result *= i--; }
return result;
}'
end
end

puts InlineTest.new.inline_factorial(5)
puts InlineTest.new.inline_pow(2, 10)



There are also way to use external C classes. For an overview see:
>https://www.amberbit.com/blog/2014/6/12/calling-c-cpp-from-ruby/
>>
>>57381523
Yea, also, gcc gives a warning when you give a wrong format for the libc printf, but not for my printf using the same format. No idea how it can do that.
>>
>>57381561
hello hellllllllllo presumably shouldn't match
>>
>>57381588
Why? They contain the same vowels in the same sequence?
>>
>>57381605
i think it should work like this
_ e _ _ o
_ e _ _ o
not like
eo
eo
>>
Any idea how to write XDCC search engine? How can I find bots and files?
>>
>>57381586
It's a GCC attribute: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
It's the "format" attribute.
>>
>>57374783
No, honestly, Vue.js 2.x is currently the hottest framework.
It's even easier than the original Angular.js, with a better performance, memory usage and ease of development compared to react.
Besides that it's comfortable to develop vue outside of the nodejs/npm ecosystem. Plain old or modern JS is enough, if that's what you fancy.

Gzipped, react is twice as big as vue.js, non minified it's 5 times as big, which speaks volumes about code quality. React is a mess.
Vue.js is practically developed by a single person (it's creator), just like vue-router, vuex and the vue development Chrome extension.

The vue.js documentation is stellar.
https://vuejs.org/guide/
>>
>>57381297
import Data.Char
vowelEq s1 s2 = strip s1 == strip s2 where strip s = filter (flip elem "aeuoi") $ map toLower s
>>
>>57379634
There's already a /dpt/ Discord.
>>
>>57379634
>>57381669
Fuck off with that shit.
>>
New thread:
>>57381675
>>57381675
>>57381675
>>
>+300

NEW THREAD

>>57381673
>>57381673
>>57381673
>>
>>57381678
Fuck, you beat me by 7 seconds.
>>
>>57381297

def vowelEq(a,b)
a, b = a.chars.grep(/[aeiou]/), b.chars.grep(/[aeiou]/)
(a + b - (a & b)).empty?
end
>>
>>57381690
>beat me
wasn't trying to beat anyone.
>>
>>57381620
just keep watching xdcc bot announcements in relevant channels and store it in some database?
>>
>>57381706
I know, I try not to race people either, but I was just pointing out how close they were.
I deleted the other thread.
>>
>>57381658
Nice, it worked with __attribute__ ((format (printf, 1, 2)));
>>
Is it a waste of time to go through programming books without exercises and which only focus on syntax? I'm doing it for HTML/CSS and I'm bored out of my mind and remember little. I've already gone through actual programming / intro to CS tutorials. (Including the first two SICP chapters
>>
>>57381751
>Is it a waste of time to go through programming books without exercises and which only focus on syntax?
Yes.

The best way to remember things is to actually need them for something; that is, to use the syntax in a project.

Come up with your own project to follow along with.
Thread posts: 325
Thread images: 36


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.