/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

en.wikibooks.org/wiki/Haskell

Previous Thread:

Other urls found in this thread:

pastebin.com/eD1cf1dY
en.wikipedia.org/wiki/Hill_equation
calibre-ebook.com/download_windows
research.microsoft.com/en-us/um/people/simonpj/papers/assoc-types/fun-with-type-funs/typefun.pdf
twitter.com/NSFWRedditVideo

dumb haskell poster

Thank you for posting anime, though.

return main

third for maki a shit

guys if any of you are familiar with graphics.py, how would I make a half-filled circle like pic related? Don't worry about pattern, just one half-filled circle.

An actual pile of shit is better than Love Live

#define GNOME KDE

>putting in OP anything but ("What are you working, Sup Forums?\n\nOld thread: >>%d", last_dpt_thread)
Yep, this thread is fucked.
We need some /dpt/ template on installgentoo wiki.

People seemed to enjoy this last thread:

>Today's challenge is inspired by the board game Scrabble. Given a set of 7 letter tiles and a word, determine whether you can make the given word using the given tiles.

import Data.List (permutations, subsequences)

main = print $ elem word $ concatMap permutations $ subsequences letters

who /fun with k-dops/ here?

i-n-e-f-f-i-c-e-n-t
u-n-r-e-a-d-a-b-l-e

Haskell: because sometimes O(2^n * n!) is good enough.

If it doesn't work fast enough for seven letters, you can approach it differently.

I made an enterprisey solution in Java.
Please post constructive comments on how we can enable buzzwords compliance.
I'm thinking big data, deep machine learning, Business Intelligence (yes, we have to build an OLAP cube), and all that jazz.
We need top tier decision support here.
pastebin.com/eD1cf1dY

Notice that enterprisey means that the code has to be simple enough that Pajeet can handle it.

Also, I'm not very good with Haskell, but do you allow substituting a character with '?' in your code?

Go back to your Java boilerplate code that takes 350 SLOC to do the same thing, m8

>Java
???

microprettification of puzzle-oriented programming languages

Have to run Qt program on WinXP. It requires some VC dlls and still refuses to work properly. How do I get my code running? It works fine on Seven and Windows 10.

Like I said, I ran it on various inputs and the result was instantaneous every time.

So yeah, sometimes "O(2^n * n!)" is good enough. What's that saying about premature optimisation?

This is undeniable even for someone who enjoys watching it

Is Ipython in Jupyter notebooks count as programming?

If so I am programming some math/physics stuff (Hill's equation) and I need to find out how I can fix all my matrix components, no bully please

XP is not supported by Qt last I checked.

>great applications made with haskell
Daily tip: is not like haskell allows bug free code, is that "hello world tier" applications hardly will contain bugs.
>hurr but muh lambda calculus
useless also in maths

>What's that saying about premature optimisation?
Is it "Haskell is only good for toy problems"?

If you were using a real language, you could write that as

$"What are you working on, Sup Forums?\n\nOld thread: >>{lastDptThread}"

how the fuck is data stored as string in C when you declare it from it's first letter pointer like this

char* mystring="hello";

either the compiler when it sees replaces this by

char * mystring =malloc(6*sizeof(char)); //hello is 5 letters +1 for the \0
mystring="hello";

or i'm missing something here. where the fuck does the data gets stored if it's not like this ?

>do you allow substituting a character with '?' in your code?

No, since I read 'letter tiles' to mean 'tiles with letters on'.

However, I fully support a Sup Forums-approved Enterprise Quality solution in Java to meet this new spec. Also all those other things you said, we should definitely implement.

Does anyone here know Java? All I can write is hilariously terse Haskell.

Actually I remember now, it was "don't feed the trolls".

en.wikipedia.org/wiki/Hill_equation

Which one?

Qt docs says that Qt supports XP

you can't do that dynamicaly without allocating, so the data is stored as part of the program in fixed memory location, which means that string will be cont

String literals are statically allocated.
It would be closer to:
static const char _storage[] = "hello";
char *mystring = (char *)_storage;
Note the cast from const, because string literals in C are not modifiable.

I'm in dire need of your help. I've been put in charge of maintaining the worst code base in existence gifted by our """senior""" developer.
The code base consists of two separate projects structured like this:
project
|
-- shared
|
-- sub project 1
|
-- sub project 2

The second project is a copy/paste from the first project with trivial changes. A project contains shared code and two sub projects. The second sub project is a copy/paste from the first sub project with trivial changes. The project defines the platform, the sub project defines the application.
The challenge is to keep the code synchronized while keeping the trivial changes. So, If I fixed a bug in project 1, sub project 1, I have to copy/paste it to while being wary of the trivial changes between projects and sub projects:
>project 1, sub project 2
>project 2, sub project 1
>project 2, sub project 2
Which is really error prone and a complete waste of my time. So, I'm looking for a way to automate this process if possible. I tried git patches, but git refused to apply the patch because it's not in the same code base. Are there any more options for me?

{-# LANGUAGE MonadComprehensions #-}
import Control.Monad (foldM)
import Data.List (delete)
import Data.Maybe (isJust)
-- all of these should be in the prelude desu --

-- remove each character in word from tiles
-- return if it succeeded (or if it failed)

check tiles word = isJust (foldM remove tiles word)
where remove string char = [ delete char string | char `elem` string ]
-- you can think of the [ x | cond ] as being "throw an exception if cond is not true"

Here's where I saw it. 4 or 5?

calibre-ebook.com/download_windows

who does the allocation then ?
for example when you do :
char mystring[5];

the compiler does it for you

but when you declare it like this
char* mystring="hello";

it works, and no one did the allocation !

>it works, and no one did the allocation!
As I said in , it's statically allocated.
The data is embedded into the executable itself.

static allocation means it's going to be on the stack, so does the compiler assume that it's going a big string and allocate a lot of memory for it ? this is not shrewd !

that's the same as doing
char mystring = {'h','e','l','l','o',0x0};

so it's being allocated somewhere in the program.
If you are using linux you can compile a little example and call the application with `hexdump -C program` and check that the string is there

5.5. I can actually run the app, but there is no sound and no network.

>MonadComprehensions
>import foldM, delete, isJust
this is the raw code, explained:

check tiles word = isJust (foldM remove tiles word)

was an exception thrown in the following code?
for each (char c in word)
- remove that char from tiles

remove string char = [ delete char string | char `elem` string ]

return string with the first occurence of char deleted ... if char is in the string
(otherwise throw an exception)

>static allocation means it's going to be on the stack
That's completely wrong.
Statically allocated things are valid for the entire program, automatically allocated things (i.e. stack allocated) are only valid for the block they appear in.
Statically allocated things usually appear in the same place global variables would.

>The data is embedded into the executable itself.
aah, got it, so it gets stored in the DATA memory segment.

thanks guys, i was really confused.

It was the first bonus point question, and part of the reason why the consumeChar method was more complex than it could have been.
Java also have a funny bug in that char might sometimes need two chars to represent a singular character. That's what you get for using UCS-16 I guess. So you have to use 32-bit ints to be sure you're not fucking your program WHEN (not if) someone use the Mongolian fingerpainting alphabet.

For the next part, I want to basically load an English word list, and put it into a map from Integer -> Collection so that I can start from the length of my letters, and find the longest word, and work my way down.
But it's late, I'm tired (we're moving offices now), so I'll look at it tomorrow.

As a BI Consultant, I find the thought of putting scrabble solutions into an OLAP-cube strangely funny. Especially since Big Data means Unstructured and/or semi-structured Data.

yes i just corrected myself, it will be on the DATA segment.

Is there any advantage for me as a developer to using GPL over more permissive licenses?

Just to be somewhat pedantic, but string literals are going be put in the rodata segment instead of the normal data segment.

Yeah, closed source companies now have to pay you money to use your stuff.

> Hey your library is really useful.
> Thank you! I've spent weeks on getting it just right.
> Can you license it as MIT so we can use it in our closed source program?
> No. But I can sell you a license.

At this point one out of two things happen:
> FUCK YOU REEEEEEEEEEEEEE
- or -
> Sure, how much do you want for a license?

what does the last expression produce?
tip:
>you should be able to solve this

(setf a 'global-a)
(defvar *b* 'global-b)

(defun fn () *b*)

(let ((a 'local-a)
(*b* 'local-b))
(list a *b* (fn) (symbol-value 'a) (symbol-value '*b*)))

>all of these should be in the prelude desu
Hell no. There shouldn't be a prelude. It should be empty.

This is neat though. Just quadratic in complexity.

>mfw I teach my dude C by K&R

He definitely will get pointer magic, but I actually fear he might not use his skills since he lacks formal STEM education.

Be a good schlomo and license your code under GPL and commercial.

>using c in 2016
how is programming dvd's working out for you

Trying to redirect to an object's action in rails.

I have a polymorphic class Invitable, all objects of this class have an action edit on their controllers, and none of them have a show action.

I can
redirect_to @some_invitable
It redirects me to the right unimplemented show page, how could I redirect to the edit action, therefore edit page?

>there shouldn't be a prelude
t. crazy

hey /dpt/
tell me what you love most about the jvm

the cache misses

The JVM is garbage.
It doesn't even have TCO.

public static int charCount(String f1, char ch1, boolean bool1) throws FileNotFoundException {
File file = new File(f1);
Scanner sc = new Scanner(file);
int charAccumulator = 0;
while (sc.hasNextLine()) {
String str = sc.nextLine();
for (int i = 0; i < str.length(); ++i) {
if (bool1 = true) {
if (str.charAt(i) == ch1) {
charAccumulator++;
}
}
if (bool1 = false) {
if (Character.toLowerCase(str.charAt(i)) == Character.toLowerCase(ch1))
charAccumulator++;
}
}
}
I'm retarded, why doesn't this work? It keeps returning the same number for both, when the case insensitive should be larger.

This.

A guy I know developed some pretty useful GPL-licensed software during his PhD and ended up being getting loadsamoney for re-licensing it to a large company. He also got a great contract at said company and continued to work on that now-proprietary codebase.

There was supposedly quite a lot of REEEEEEEEing among academics he knew because half the field came to depend on a tool developed by a single PhD student and no one stepped in to continue maintaining a free version.

>public static int

but user why do you need that
you can solve all those problems iteratively

the fact that I can eat curry with my friend in amrita university while listening the lectures of our dear Shafiq Khan Mohammad

t. idiot gay white american millennial falseflagging hard

Clojure.

You literally have the same benefit with no license though.

It's permissive licenses which reject it, not GPL which adds it.

mad?

Checking for an empty intersection of two sets of (letter, count) pairs would probably be just as concise and not as embarrassingly inefficient.

>using a Sup Forums meme

>meme
>le returning from le reddit once again!

>a word is a Sup Forums meme.

ok spajeety

Not OP but why would the method being static or not matter in this case? I don't see any reason why it would, unless if I'm retarded as well

>but I actually fear he might not use his skills since he lacks formal STEM education

It's not that, he will not use his skill because C is niche nowadays on the job market.

Unless he'd want to work with embedded systems and what not but in which case they're not gonna take some newcommer.

My professor made a test for our methods that we have to use and when I delete static it gives me the error Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Cannot make a static reference to the non-static method charCount(String, char, boolean) from the type Operations
Cannot make a static reference to the non-static method charCount(String, char, boolean) from the type Operations

at TestOperations.main(TestOperations.java:59)

then the test is faulty

using namespace std;

//This is a comment, it won't be part of the code:
//this is a program for determining if a group of 7 letters can be used to make a specific word.

string word{"whatever"};
string letters{"whatever"};

string blurf = letters;
for{auto c : word}
{
for{auto l : blurf}
{
if(*c==*l)
blurf.erase(l),
if(c==word.end()-1)
cout

I was thinking to learn somehting to use with the jvm (but not java). I was between scala or clojure. How is clojure in your opinion? have you used scala? how they compare?

Hey guys, I have an open-ended term project for a second year comp sci class. I need to make a project in java and the only requirement is that it is comprised of at least 4 class files. I'm clueless as to what to make. Any recommendations?

>using namespace std;
really?

Enterprise fizzbuzz.

Make a graphing calculator like desmos, but shittier, ofc

this is truly the greatest /dpt/ meme of them all
>implying anyone ever encountered a problem because he used 2(!) std's

just overcomplicate a simple process like addition.

//This is a std::comment, it won't be part of the std::code:
//this is a std::program for std::determining if a std::group of 7 std::letters can be std::used to make a std::specific std::word.

std::string std::wordstd::{"whatever"};
std::string std::lettersstd::{std::"std::wstd::hstd::astd::tstd::estd::vstd::estd::rstd::"std::}std::;

std::string std::blurf std::= std::lettersstd::;
std::forstd::{std::auto std::c std::: std::wordstd::}
{
std::for{std::auto std::l std::: std::blurf}
{
std::if(*std::cstd::==std::*l)
std::blurf.std::erase(std::l),
std::ifstd::(std::cstd::==std::word.std::end()-std::1)
std::cout

>/dpt/ meme
Many mainstream coding standards (e.g. Google's) explicitly forbid it.

It defeats the entire point of namespaces, lowers readability, and is a common source of bugs and unexpected behaviour.

I vote this. See section 2.2:
research.microsoft.com/en-us/um/people/simonpj/papers/assoc-types/fun-with-type-funs/typefun.pdf

>caring what SJeWgle has to say

lmao

std::whats std::your std::problem

man that's so readable
now you can start working for google

>unironic greentexting
I don't want him to be like that dumbfuck who said crap like "Python 3 is not Turing-complete language", I want him to know how do computers operate, so they wouldn't be big grey howling boxes for him, but powerful machines, what can give the most, if needed.

Yes, that's kind of what I mean.
Embedded engineers least possibly will take a guy without STEM education.
We just started with him, though, maybe he'll say "Fuck that shit", and will drop learning C. On the other hand, his alternatives aren't better - hell, he's a historian.

>std::meme
>I got tired of le reddit, better to shitpost in le Sup Forums

never been to reddit, my shitposting is 100% good old Sup Forums

Python 3 can't run Python 2 code. If it were Turing complete, it would be able to perform arbitrary computation. Since it can't, it isn't.

Sexually Transmitted Disease?

Good meme, my fellow

>//
this should be
std://

this is another /dpt/ meme I love so much

keep dem memes coming brehs

If Zed Shaw said it, it must be true.

Why don't you protect your libraries from sepples fags by putting header files full of C that won't compile with C++ compiler.

literally who the fuck

You can avoid all those pesky STDs with this simple code

#define condom namespace std
using condom;

>doesn't know who ZAS is
No wonder you're still using python3.