/dpt/ - Daglig programmeringstråd

Hva jobber dere med, Sup Forums?

Gammelt tråd:

Other urls found in this thread:

forum.dlang.org/thread/[email protected]
stackoverflow.com/a/1732454
developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/
github.com/scalaz/scalaz/blob/series/7.2.x/core/src/main/scala/scalaz/Endomorphic.scala
twitter.com/NSFWRedditGif

Erste fuer D

Stop with this stupid non-english meme.

I alle dager, jeg trodde at browseren hadde bynt å oversette automatisk jeg. Man skal jo egentlig skrive på engelsk her.

I do python scripts to make plots and charts. It's pretty straight forward work, just tedious.

worse than trapshit tbqh 'f'+'am'

Kan dere ikke snakke norsk?

forum.dlang.org/thread/[email protected]

I have learned that hacking something together instead of doing it properly never pays off in the end.

Is there a better way to write this without it looking so retarded and repetitive?

var xml = fs.readFileSync('./metadata.opf', 'utf8');
var final = {};

// Grabbing important meta from opf file.
if (xml.match("opf:role=\"aut\">(.*)")){
final.author = xml.match("opf:role=\"aut\">(.*)")[1];
} else { throw (new Error("no author"));}
if (xml.match("(.*)")){
final.publisher = xml.match("(.*)")[1];
} else { final.publisher = "unknown";}
if (xml.match("(.*)T")){
final.date = xml.match("(.*)T")[1];
} else { final.date = "unknown";}
if (xml.match("(.*)")){
final.title = xml.match("(.*)")[1];
} else { throw (new Error("no title"));}
if (xml.match("(.*)")){
final.isbn = xml.match("(.*)")[1];
} else {final.isbn = "no isbn";}

tfw your boss insists that you can catch exceptions thrown by the delete operator in C++ when their signatures are marked noexcept

Stop trying to parse XML with regular expressions, you fucking idiot.

1. Pull your regexes out into variables.
2. Create a class to represent a regex, the attribute to set if a match is found, and the action to perform if no match is found (tip: make it a function). Make a list of instances of this class and iterate through it.

posted in the last thread but here it is again:

Working on this problem for my Python class, but my program makes no substitutions to the txt file. Any help would be appreciated.

try:
myfile = open("bieber_baby.txt", "r")

except:

print("Sorry, the file doesn't exist")

else:
print("Total words in thesaurus: ", total_words)
lyrics = myfile.read()

#remove punctuation from the file

lyrics_no = ""
for word in lyrics:
if word.isalpha():
lyrics_no += word

elif word.isspace():
lyrics_no += word

#split by word
word_lyrics = lyrics_no.split("\n")

#ask the user to enter a probability of changing lyrics

chance = float(input("Enter a % chance to change a word: "))

#Blank list of altered lyrics
audio = ("")

#examine each line
for line in word_lyrics:

#split the line to make into string of words
words = line.split(" ")

#make a program to decide whether to alter words or not
for c in words:

swapnum = random.randint(1,101)

#Check if the words should change by probability and by existing in thesaurus
if (swapnum

You never open the file for writing.

Read this: stackoverflow.com/a/1732454

2012 says hi

Anyone have a link to a good tutorial to developing on iOS, including platform to use (I currently have XCode -- not sure if that's a good one to use)? I'm on a Mac, if that helps.

I found this, but not sure if it's a good tutorial
developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/
(I also don't know Swift.) I'd rather develop on Android since I already know Java, but everyone I know has an iPhone, and I can't get word-of-mouth going as well (on an immediate, personal level) on Android, even if the latter has a larger user base.

You have to actually write to the file.

And guess what, it's still relevant because retards like him are still using regex to parse XML

wait I fucked up, I don't actually need to edit the .txt file for the problem. I just need to print out the edited text. Do I still need to write to the file in this case?

No.

Snakker på engelsk, motherfucker.

No, you just have to read the file and then print out an edited version. How you do that is up to you.

How do I make something like this:
spaceengine.org

Repost:Are there any C# + F# programmers here? I'm primarily (read: entirely) a Lisp developer for the past couple of years but I'm really starting to feel some friction from lack of libraries and lack of good compiler/editor integration*.

I'd like to learn F#, but do I need to learn C# first? How good is the interop between them? Apparently if your program uses a GUI you still need to use C# for it. Will I be able to just whip up a straightforward GUI and do all of my programming in F#? I haven't found any guides or tutorials (or even many people) aimed towards people who are in my particular situation of being more comfortable with functional programming and dynamic typing than their reverse.

tl;dr
>How well does F# work on its own, and can it be learned without knowing C#?
>How well does F# work inside of a C# interactive GUI program?

The code I've written just strips out punctuation and prints the text as one whole block without line breaks or synonyms. Any suggestions?

Först må du lære norsk.

Fire up a debugger and step through your code to see what's happening, and compare it to your expectations.

Not a .NET programmer but I imagine there's lots more .NET library tutorials available for C# than for F# so it probably pays to be able to read C# a little. Wouldn't spend ages learning it though.

Er dette en ny meme?

I'm scraping for 5 values from a file that at most 20 lines. An xml parser seems like overkill. Everything works just fine, I just thought it looked silly.
That actually makes a lot of sense, thank you.

Ja

Sérieusement /dpt/, arrêtez de parler dans un langage non anglophone.

I hope Andrei-sama responds to me on the dlang forums

Why is programming high so much harder than programming drunk?

do you want him to give you the d

The interop is 1st class, 99% of stuff just werks. I've written applications with GUIs in just F# before. Small utilities to make life at work easier. You don't get the standard nice tools for the job, but it's entirely possible, albeit tedious.
Knowing C# is a bonus though

Like you wouldn't believe user

Pls, you're supposed to program for correctness, just cuz it werks doesn't mean it's correct.

Try focusing on just doing a single word or a single line as a proof-of-concept, perhaps with a string you've made up yourself. I don't feel like looking at your code or spoonfeeding you, but you're probably doing something wrong with an if-statement. Probably a logical error.

desu I tried to use an xml parser, but all the ones for node had so little documentation I had no idea how to get the values out.

Hard to process shit logically when high imo

>I've written applications with GUIs in just F# before.
Are there any guides for this? I found some short articles on functional reactive programming for events, but that's it. This is good to know though.

thank you for using an anime picture

tests=[
'pattern1',
'pattern2',
'pattern3'
];

for(pattern=0;pattern

Functional programming is great and all, but near impossible to debug using conventional means, especially when you're mucking about with continuations, endomorphisms, etc.

I've used it successfully with phrases I created through an input command. But it doesn't seem to work when I use a text file. I just don't see why it's not working.

True, true. I was actually surprising myself when coding drunk a couple weeks ago. Almost too drunk to walk but was writing great code. I had to go back and re-read it sober to figure out what I did.

Yet right now I'm barely high and coding is really difficult. The ballmer peak is real

hmm


tests=[
'pattern1',
'pattern2',
'pattern3'
];

for(
pattern=0;
pattern

>looks better don't it?
Not really

>is probably more readable as well
No again

Continuations aren't used in regular programming. They're deliberately intended to use in a very, very low-level in limited situations in order to construct a new control-flow for a specific operation. It's like a programmable goto. Use delimited continuations to help avoid manually debugging unwind.

You use them with the same restrictions and care that you would when modifying the control flow of any other programming language. Of course, most other programming languages don't allow you to modify control flow outside of the already-given syntactical structures like for, goto, etc. to stop you from shooting yourself in the foot.

At each step, print out whatever data is important for that step, doing this one step at a time, making sure each step is done correctly. For instance, make sure you're adding the right string/transformation to your list. Printing shit out is the easiest way to make sure individual steps are functioning properly.

If he were using a real language he could use a debugger instead of having to put print statements everywhere in his code.

But there's absolutely nothing special about endomorphisms in programming.

hmmm

tests=[
'pattern1',
'pattern2',
'pattern3'
];

for(p=0;p

just noticed that I made the same mistake

xml.match(tests[p])

why is this thread so dead
why are you all incompetent js shitters

desu he should have just done what I said at each step in the first place since he's dealing with a language he's only just learning. Python is starting to become a useful thing to know in the industry tho, for whatever reason

Post some code, you humongous cock-guzzling cumslut faggot

what's the best non-english programming language?

I don't even really know memescript, so I had to look most of this shit up, but here is a cheeky way of doing it:
xml = "asdf"

var call = (fn) => typeof fn == "function" ? fn() : fn
var extract = (re, def) => (xml.match(re) || {1: call(def)})[1]

var final = {}

final.author = extract(/(.*)/, () => {throw "no author"})
final.publisher = extract(/(.*)/, "unknown")
final.date = extract(/(.*)/, "unknown")
final.title = extract(/(.*)/, () => {throw "no title"})
final.ibsn = extract(/(.*)/, "no ibsn")

console.log(final)
Ignore that all of the regexs are the same, I just couldn't be bothered writing a test xml string to match all of that shit.
Obviously if you were going to use this, you would change them.

moon

Applying EPX 2x to the generated stippled images is pretty neat.

What's the output if you run this through it? Just curious

>language looks like puke when typed out
>sounds like puke when spoken

how do you put up with this?

Same is true for any other programming paradigm when you indirect yourself five dozen layers from the baseline. Debugging advanced template systems in C++. Debugging complex Javascript systems. Debugging any sufficiently large Python program...

can mongodb find specific data instead of just the entire entry?

I want to start developing some applications for linux. These applications will mainly handle media like images and video files, which language should I choose?

>Andrei replied to me

>mucking about with [...] endormorphisms
What? What is there to "muck about with" there? An endomorphism is just Haskell-shitter speak for "a function whose return type is the same as its input type" and those aren't specific at all to functional languages. Every language with types has them.

C

github.com/scalaz/scalaz/blob/series/7.2.x/core/src/main/scala/scalaz/Endomorphic.scala

Here, boss.

C++

>Recommending C++ to anybody for any purpose
(You)

Norsk er et musikalsk språk.

That's what I thought, I just wanted some confirmation

Fritjof, du suger pikk.

How do I be less tired after commuting 90 minutes each way to my programming job?

Move closer.
If your job is stable enough, make the effort to move closer to where you work.
Having a sub-20 minute commute is a real quality of life upgrade.

Lots of caffeine.

Endomorphism has the same meaning, even in Scala, user.

Get more sleep, and dream of the day when we have the technology to allow you to work from home.

For sublime syntax definitions, are there specific predefined scopes, or are they completely user defined?

Can't. Wife needs to commute in the opposite direction.

>wife
You made your bed, now lay in it.

>spending 3 hours commuting
why even live?

I'd rather be homeless than deal with that nonsense.

...

I have a 65-70 minute commute. I use the extra time to contemplate suicide.

Great time to read a book if you're going by train desu senpai

In C with a pointer foo, can I do

if (foo != NULL && *foo == bar) {
...
}


or do I have to do

if (foo != NULL) {
if (*foo == bar) {
}
}


?

Compile it and see.

WHAT THE FUCK I HATE C NOW

Should be fine, look up short-circuit evaluation

>train

This is America, god damn it.

>being forced to work in the field
Great time to socialize and get a tan

I used to use the tone to try to learn moon but I stopped being able to concentrate. These days I never feel fully awake. Like I'm trapped in an unending nightmare.

I love my 30 minute commute because I live in a city but work in the countryside.

Every morning I get to freely pass thousands of furious people stuck in traffic going in the opposite direction and finish my journey among green rolling hills.

Then when I go back I get the same thing in reverse.

It feels really good.

Nigga I ain't driving in Chicago

I know the top version works, I just don't how about about any hidden gotchas (e.g. with standard/compiler compliance) that might be hiding.