[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: 328
Thread images: 46

File: ritsuko3.jpg (18KB, 500x335px) Image search: [Google]
ritsuko3.jpg
18KB, 500x335px
What are you working on, /g/?

Old thread: >>57904730
>>
What's the most conceptually interesting thing you guys have worked on?
>>
A distributed hardware, software, and network resource abstraction layer. It's just a decentralized remote desktop session with some extra features taped on. Cant do more that 4 clients yet, don't even have keyboard/mouse integration working. Thinking I might give up. Im overengineering a solution that doesnt have a problem.
>>
>>57911337
so, a cluster with ltsp on top?
>>
Any recommendations for a .NET compatible GUI framework? Something minimal, I don't want to spend weeks learning something like WPF when all I need is a basic interface.
>>
Reminder that do notation needs to be generalized.

When you have the statements
x <- foo; bar x
this is currently translated to
foo >>= (\x -> bar x)
. Wouldn't it be better if the continuation passing style was focused on instead of limiting it to monads? Instead, those statements would be translated to
foo (\x -> bar x)
. To recover monad syntax, use
bind :: Monad m => m a -> (a -> m b) -> m b
:
x <- bind foo; bar x
.
>>
File: MVI_2667.webm (1MB, 1280x720px) Image search: [Google]
MVI_2667.webm
1MB, 1280x720px
>>57911285
Why the fuck are you all stupid plebs?
>>
>>57911368
>baby's first dev board

At least it's not blinky.bin
>>
>>57911360
Yes, I think everyone agrees
use rebindable syntax

Also sequencing in do notation should be seperated from continuation passing.
>>
>>57911384
>implying first
it is an attiny13 running a hd44780 with a shift register. Programmed in pure C. Wasn't as easy as it sound though.
Runs at ~800 bytes atm
>>
>>57911404
>use rebindable syntax
Huh, I suppose you can just define >>= to be application. Never thought of that.

>Also sequencing in do notation should be seperated from continuation passing.
Continuation passing IS sequencing.
>>
>>57911360
>>57911404
e.g.

class Sequence a b | a, b -> c where
(>>) :: a -> b -> c
class Continue a b c | a, b, c -> d where
(>>=) :: a -> (b -> c) -> d

and

instance Applicative f => Sequence (f a) (f b) where
(>>) = (*>)
instance Monad m => Continue (m a) a (m b) where
(>>=) = (M.>>=)


Or perhaps even better, we could go even further beyond

continuation -> arrow
>>
File: wire defusal problem.png (277KB, 2780x860px) Image search: [Google]
wire defusal problem.png
277KB, 2780x860px
>>57911431
Not all sequencing is continuation passing

See this overly posted image for an example.
>>
>>57911418
>Wasn't as easy as it sound though.

Sure it was. Now, hook up a ROM chip loaded full of pixel porn if you want to impress us.
>>
>>57911441
And another way of doing this, with continuation passing, would've been to have added an extra type parameter, and make all of those cutting actions to be (some specific m) Monad m => m (), and then add Pure.

But it's unnecessary, and you don't always want people to be able to put functions into your data type
>>
>>57911418
I can't think of a single justifiable reason that that would require anywhere near 800 bytes of code.
>>
>>57911441
Very true, sometimes you might want only >> and not >>=.
>>
>>57911285
The webm converters on gentoo wiki didn't work for my computer, so I used python and tkinter to make my own GUI to send commands to ffmpeg

I'm finally making programs that are useful (to me)
>>
File: 1479286874867.jpg (174KB, 633x758px) Image search: [Google]
1479286874867.jpg
174KB, 633x758px
>mfw no definition of what scripting language is
>mfw can't shittalk at those, who make big program systems in scripting languages just because you can't definitely say is their programming language actually scripting language
>>
>>57911496
>not invoking ffmpeg directly
you will not survive the academy
>>
>>57911554
Your mom's a scripting language
>>
>>57911563
>>57911554

sorry that was rude
>>
>>57911554
Assembly is a scripting language. You're just writing a bunch of mnemonics that call microcode on the CPU.
>>
File: ip-request.webm (3MB, 853x480px) Image search: [Google]
ip-request.webm
3MB, 853x480px
>>57911452
is this enuff? :(
>>57911492
FUCK YOU'RE MOM YOU STUPID NIGGER
>>
If I ask you guys to help me with [spoiler]my homework[/spoiler] will that be okay or should I just fuck off back to /sqt/?
>>
>>57911627
Make a calculator
>>
>>57911627
I'm not seeing any big ole anime tiddies on there
>>
>>57911630
you can do fizzbuzz you'reself, m80
>>
>>57911630
Forgot spoilers don't work on this board.
>>
Is PyQt shit?
>>
>>57911643
Fizzbuzz for homework? I'm not so sure I've heard that one yet.
>>
>>57911588
Kill yourself, shit stain.
>>
File: 1480383386969.png (899KB, 1600x901px) Image search: [Google]
1480383386969.png
899KB, 1600x901px
>>57911681
>>
>>57911602
CPU doesn't execute raw mnemonics, they get translated into binary.
>>
>>57911723
Wow, it's almost like you managed to define the "mnemonic" in "mnemonics"!
>>
File: 1477319531144.jpg (13KB, 142x250px) Image search: [Google]
1477319531144.jpg
13KB, 142x250px
>>57911723
CPU doesn't execute raw binary, they get translated into electrical signals
>>
>>57911762
this
>implying binary actually exists at a low level
HIGH and LOW are just an abstraction
>>
>>57911781
>HIGH and LOW are just an abstraction
No
>>
>>57911781
>binary doesn't actually exist

Then explain decapping. You can actually see the bits under a microscope.
>>
>>57911781
>>57911796
It's more like high/low are only good as relative quantifiers, not absolute.
>>
>>57911804
No, you are 100% wrong.
>>
void fn() {
int x[128];

for (int i = 0; i < 128; i++) {
if (x[i]) return 1;
}

return 0;
}


Is this guaranteed to return 0 in C?
>>
A Perl script to AutoTag all my music files and update Album Art from CoverArtArchive
>>
>>57911026
It seems WM_NC(L/R)BUTTONDOWN just blocks until the event ends. I found you can get the clicked object by passsing WM_NCHITTEST into DefWindowProc. I'm just blocking right clicks to the title bar, allowing left click on maximize/minimize/close to go through, and re-implementing window dragging myself with clicks to the title bar.

It wasn't exactly what you said, but it did lead me to the answer so thanks for the help. This is a problem I've had for a long time and I'm glad to have a real solution.
>>
>>57911961
No. all of x is uninitialised, so all you're reading is garbage. Maybe it'll be 1, maybe it'll be 0, but really, it's undefined behaviour.
If you want to zero initialise an array, do this:
int x[128] = {0};

Also note that you're trying to return a value from a void function.
>>
>>57911796
>>57911819
They're right, you idiot.
"High", "Low" and their tolerances are whatever the hell you define them to be.
You really need to learn some basic electronics.
>>
File: 1476713479124.jpg (204KB, 1920x1080px) Image search: [Google]
1476713479124.jpg
204KB, 1920x1080px
AoC day 9 is being a bitch.
How do I decompress 10GB worth of data without actually storing any of it?

I don't have that much ram.
>>
>>57912203
I'm not following the advent of memes or whatever, but I suppose I'll look at it.

Why do you even need to store anything? You only need to get the length of the output.
When you come across one of the markers, just calculate the length it would take, then jump forward.
>>
>>57912265
In part 2, you're also supposed to keep expanding any markers that were duplicated by previous markers.
If I just keep multiplying the length and adding it, It won't come out to anywhere near 10GB.
>>
any of you lads ever design your own lang
>>
>>57912320
>part 2
Does this unlock or something when you submit the first solution?
I have no intention of signing up to this site to find out.
>>
>>57912095
>he doesn't know how to return void literals
>>
I64 Cnt(I64 n)
{
I64 i;
for(i=0;i<=n;i++)
"%d\n", i;
return 0;
}


It works :^)
>>
>>57912382
in haskell this is just

cnt _ = 0
>>
>>57912394
doh!! I meant return n;
>>
int main() { return 0; }
>>
>>57912420
int main() { }
>>
>>57912420
> C++
>>
>>57912355
Are you one of those non-free javascript autists?
You sound like one.

Part 2 unlocks once you finish the original puzzle.
It basically punishes you for terrible program design if you tried to take the easy way out with the first part, like for example, blindly counting numbers and not actually simulating what they represent.
>>
>>57912428
okay
Class Main { public static final void main(String[][] theArgs) { return void; } }
>>
>>57912449
>non-free javascript autists
what does this even mean
>>
daily haskell nigger thread

watch each of your queries receive a tangential response that always relates back to haskell, no matter what language you were discussing initially
>>
>>57912459
main = pure 0
>>
>>57912449
Are you one of those proprietary javascript autists who needlessly slaps social media and other shit onto every website?
You sound like one.
>>
>>57912487
>>57912489
nice timing
>>
>>57912491
>>57912480
You don't have to be so bitter.

Anyways, I just set it to auto-truncate every million iterations.
It should take about 3 hours to finish.
I'm going to bed~
>>
>>57912549
>It should take about 3 hours to finish.
Jesus christ, I don't know exactly what you're doing, but it's completely wrong.
>>
>>57912569
pls dont bully
size_t decompress_v2(char **loc)
{
char *arr = *loc; /* realloc */
size_t i, j, length = 0;
for (i = 0; arr[i]; i++)
{
char *next = strstr(&arr[i], "(");
i = (!next) ? strlen(arr) : (size_t) (next - arr);
if (!arr[i]) break;

/* extract and parse marker */
unsigned dist, iters;
for (j = 0; arr[i + j] != ')'; j++);
j += 1; /* catch last parens */
char *mark = (char *) malloc(sizeof(char) * j + 1);
memcpy(mark, &arr[i], j);
mark[j] = '\0';
memmove(&arr[i], &arr[i + j], strlen(&arr[i + j]) + 1);
sscanf(mark, "(%ux%d)", &dist, &iters);
free(mark);

/* extract region from string and copy back */
char *cpy = (char *) malloc(sizeof(char) * dist + 1);
memcpy(cpy, &arr[i], dist);
cpy[dist] = '\0';
memmove(&arr[i], &arr[i + dist], strlen(&arr[i + dist]) + 1);
unsigned inserted = dist * iters;
arr = (char *) realloc(arr, strlen(arr) + inserted + 1);
for (j = 0; j < iters; j++)
{
memmove(&arr[i + dist], &arr[i], strlen(&arr[i]) + 1);
memcpy(&arr[i], cpy, dist);
}
free(cpy);
if (i > 1000000) /* truncate */
{
length += i;
printf("v2 length: %zu bytes\n", length);
size_t trunc = strlen(&arr[i]);
memmove(&arr[0], &arr[i], trunc + 1);
arr = (char *) realloc(arr, trunc + 1);
i = 0;
}

}
*loc = arr;
return length + i;
}
>>
>>57912652
Post a screenshot of part 2. I want to try and solve it.
What you're doing there seems needlessly complicated
>>
>>57912203
Read chunk
Decompress chunk
Write chunk
Repeat for next chunk
>>
File: Day 9 Advent of Code 2016.png (347KB, 1265x1815px) Image search: [Google]
Day 9   Advent of Code 2016.png
347KB, 1265x1815px
>>57912745
>>
>>57912382
Disgusting.
>>
>>57912775
Can you also pastebin the input or whatever?
>>
>>57912803
do it yourself
>>
How the fuck do I get
Symbol:        Open:        Close:
___________________________________________
BAC 13.20 13.38
PFE 28.11 28.26
S 7.34 7.24
MRK 48.60 48.19
GE 23.38 23.86
CSCO 24.55 24.49
MSFT 34.96 35.67
F 15.44 15.73
INTC 24.65 24.59
MS 25.41 27.00


to show me which one of these lines gained value or lost value in Python
>>
>>57912896
>he doesn't know how to parse CSV
kys cuck
>>
>>57912910
>parse CSV
show me fampai
>>
>>57912896
To extend on this:
Symbol:        Open:        Close:
___________________________________________
BAC 13.20 13.38
PFE 28.11 28.26
S 7.34 7.24
MRK 48.60 48.19
GE 23.38 23.86
CSCO 24.55 24.49
MSFT 34.96 35.67
F 15.44 15.73
INTC 24.65 24.59
MS 25.41 27.00


needs to show up like this:
Symbol:     Change:     Change(%):
__________________________________

Gainers:
BAC +0.18 +1.36
PFE +0.15 +0.53
GE +0.48 +2.05
MSFT +0.71 +2.03
F +0.29 +1.88
MS +1.59 +6.26

Losers:
S -0.10 -1.36
MRK -0.41 -0.84
CSCO -0.06 -0.24
INTC -0.06 -0.24


I've tried splitting the entire line into an array
I've tried using dictionaries
Nothings really working out...
>>
im writing a compiler using Bison and trying to get the ternary tree for the parsed code up and going, but then i got to this bit
FOR IDENTIFIER IS expression BY expression TO expression DO statement_list ENDFOR


is the correct solution to split this into two clauses (one for the loop head, one for the body), or to expand the tree nodes to fit the number of arguments?
>>
>>57912775
>>57912808
>>57912652
Ok, here is my entire solution. I don't have the input data, so I can't give the answer, but it works for their examples.
It's a bit light on the error handling, but I don't think it's that important for code like this.
Also note, it's likely that your text editor will add a newline at the end of your input file, which may make the length be 1 bigger than it's supposed to be. Turn automatic newline off in your text editor.
#include <stdio.h>
#include <stdlib.h>

#include <sys/types.h>
#include <regex.h>

regex_t re;

int length(size_t len, char str[static len + 1])
{
int n = 0;
char saved = str[len];

/* Null terminate substring, to stop regexec looking too far */
str[len] = '\0';

for (char *ptr = str; ptr < str + len;) {
regmatch_t m;

if (regexec(&re, ptr, 1, &m, 0) == REG_NOMATCH) {
n += str + len - ptr;
break;
}

/* String leading up to marker */
n += m.rm_so;

int num_chars, repeat;
sscanf(ptr + m.rm_so, "(%dx%d)", &num_chars, &repeat);

int sublen = length(num_chars, ptr + m.rm_eo);

n += sublen * repeat;
ptr += m.rm_eo + num_chars;
}

str[len] = saved;
return n;
}

int main(int argc, char *argv[])
{
if (argc != 2) {
return 1;
}

FILE *fp = fopen(argv[1], "rb");
if (!fp) {
perror(argv[1]);
return 1;
}

fseek(fp, 0, SEEK_END);
long len = ftell(fp);
fseek(fp, 0, SEEK_SET);

char *str = malloc(len + 1);
fread(str, 1, len, fp);
str[len] = '\0';

regcomp(&re, "\\([0-9]+x[0-9]+\\)", REG_EXTENDED);

printf("%d\n", length(len, str));

regfree(&re);
free(str);
fclose(fp);
}
>>
I have a game, and in this game multiple classes have collision functions, each of which uses ~10 mega flops of computing.

How would I use multi threading to make this more efficient? Can I create a threaded class which has half of these calculations sent to it, and have it return the values?
All of the classes need to be able to send values back and forward
I'm using Java btw
>>
>>57913518
>multiple classes have collision functions
That's the wrong way to do collision.
You want a single quadtree (or similar data structure) and do all of your collision calculations from that.
Damn OOPfags.
>>
>>57913538
Also, I forgot to mention:
I assume you're doing 2D. If it's 3D, shit gets more complicated.
>>
>>57912033
Happy to have helped.
>>
>>57913518
You decided to do OOP (probably).
Best re-learn programming before you go any further.
>>
>>57913518
>each of which uses ~10 mega flops of computing.
This is per function right? Why are all your classes collision functions used equally? Why are you measuring that and not what an individual iteration takes on average and worst/best case?
Why are you not measuring what you'd expect the computation to take in cycles?
>>
>>57913538
I assume Box2d has its own quadtree, if it does, I'll rewrite my code and create sensor objects
But there doesn't seem to be any documentation on this
>>
File: keanster.png (125KB, 506x285px) Image search: [Google]
keanster.png
125KB, 506x285px
Currently working on r/dailyprogrammer challenge #294.

"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."

>inb4 reddit i suppose
>>
File: ada.png (4MB, 4800x2700px) Image search: [Google]
ada.png
4MB, 4800x2700px
>>57913655
>i suppose
I wonder who could be behind this post
>>
>>57913638
Theres collision detection being done in Box2d, and some being done in liquidfun. I have no idea how many flops it takes to do this.

Theres also a bunch of functions that are only called under certain conditions etc. It's not a standard platformer with 100 rectangle objects, so I can't easily quantify the total flops for the collisions
>>
File: BRETT KEANE WITH TEETH.jpg (17KB, 400x300px) Image search: [Google]
BRETT KEANE WITH TEETH.jpg
17KB, 400x300px
>>57913673
My name is actually Brett Keane, from God-TV Radio, make sure you check out my gaming channel (gamesUlove), and subscribe to me on youtube.
>>
File: Mar_01.jpg (57KB, 336x1008px) Image search: [Google]
Mar_01.jpg
57KB, 336x1008px
I am going to learn Android development.
Is the udacity course good?
https://www.udacity.com/course/new-android-fundamentals--ud851

Or do you have any other suggestions on where to start of learning Android that's better?
>>
>>57913681
>so I can't easily quantify the total flops for the collisions
Well anon I'd say you need to put yourself to work to learn to profile your code before you aim to optimize.

Trying to fix something from a broad overview of the performance of the situation just doesn't get you much since you don't know where to focus your effort.

You have to know the problem before you solve it.
>>
File: DB.png (45KB, 1462x725px) Image search: [Google]
DB.png
45KB, 1462x725px
>>
File: CTRL.png (41KB, 1393x681px) Image search: [Google]
CTRL.png
41KB, 1393x681px
>>57913791
>>
File: GUI.png (47KB, 1047x704px) Image search: [Google]
GUI.png
47KB, 1047x704px
>>57913818
>>
>>57913791
>>57913818
>>57913825
Why the fuck wont it update the database
>>
>>57913834
You wrote it in Java.
>>
>>57913655
type Scrabble = ExceptT () (State String) ()

stricken :: Char -> Scrabble
stricken c = do
b <- gets (elem c)
unless b $
throwError ()
modify (delete c)

check :: (Foldable f) => String -> f Char -> Bool
check tiles word = run (mapM_ stricken word)
where run = isRight . flip evalState tiles . runExceptT
>>
File: VID_20161209_130615272.webm (1MB, 1920x1080px) Image search: [Google]
VID_20161209_130615272.webm
1MB, 1920x1080px
building a remote for muh EOS700D

gonna make it wireless with either 433mhz receivers or nrf24l01 modules not sure.
Prolly the latter ones. A little bit overkill, but wanna get used to em
>>
let's say for the sake of meming i want to do slight modifications to the linux kernel, compile it and install it on another computer using an usb key, do you have any advice? especially on what i should modify even for have 5 mins of fun and then format
>>
>>57913655
>>57913914
updated
-- deleteAt i list returns list without the i'th element
deleteAt i l = a ++ drop 1 b where (a, b) = splitAt i l

find = MaybeT . gets . findIndex
matches c k = (c == k || k == '?')

stricken c = do
b <- find (matches c)
modify (deleteAt b)

-- the important bit --
check tiles word = run (mapM_ stricken word)
where run = isJust . flip evalState tiles . runMaybeT
>>
Why does /dpt/ love functional programming now? Member when /dpt/ hated functional programming?
>>
>>57914093
oh, and I changed ExceptT () to MaybeT
>>
File: 5.png (395KB, 680x665px) Image search: [Google]
5.png
395KB, 680x665px
Why does /dpt/ refuse to use JavaScript?
>>
>>57914143
Fuck you for asking
>>
>>57914143
Because there exists /wdg/ for Javascript.
>>
>>57914114
Because we killed the memers
>>
>>57914166
But JavaScript isn't just about web development, see nodejs.

Also, even JavaScript related web development is suitable to post on here. At the end of the day, JavaScript is a programming language.

/wdg/ is a shit general that just splits discussion.
>>
>>57913791
>>57913834

Are... Are you from India?
I mean, if we disregard the atrocious code quality, you specifically asked for that.

/* WARNING: This was written on Notepad on a computer without a Java development environment set up. So some syntax is bound to miss. It's still better than your code. */
public void updateProduct(Product product) throws SQLException {
String query = "UPDATE Product SET productName = ?, description = ?, price = ?, quantity = ?, location = ? WHERE productID = ?";
try(Connection conn = DBConnection.getInstance().getDBcon();
PreparedStatement update = conn.prepareStatement(query)) {

/*
* This means that we tell our SQL database to not commit any changes to the database
* until we specifically tells it to.
* This means that we can try to do a whole lot of stuff, and then if anything goes bad, we can
* undo everything by calling the rollback method.
* The bad news is that we have to call the commit method manually afterwards.
*/
conn.setAutocommit(false);

update.setString(1, product.getProductName());
update.setString(2, product.getDescription());
update.setDouble(3, product.getPrice()); // Notice that in real life we NEVER EVER use floating point for monetary values. VARCHAR, Int(64) and DECIMAL(18,2) are popular choices.
update.setInt(4, product.getQuantity());
update.setInt(5, product.getLocation());
update.setInt(6, product.getProductID());
update.executeUpdate();

// Now, notice how we're not yet committing our changes to the database? We totally should. Because we want the changes to happen.
conn.commit();
}
catch(SQLException sqle) {
sqle.printStackTrace(System.err); // This could be a logfile or what have you.
throw sqle; // we rethrow the error right away, since the method calling here should be notified.
}
}
>>
why does the following spit out unknown type errors?

%token ADD SUBTRACT MULTIPLY DIVIDE BRA KET COLON SEMICOLON COMMA DOT ASSIGN EQUAL NOTEQUAL LESSTHAN GREATERTHAN LESSTHANOREQUAL GREATERTHANOREQUAL CHARACTER INTEGER REAL OR AND NOT READ WRITE NEWLINE FOR IS BY TO DO ENDFOR WHILE ENDWHILE ENDDO IF THEN ELSE ENDIF OF TYPE DECLARATIONS CODE ENDP CHARACTER_CONSTANT FULLSTOP PLUS EQUALS

%type<tVal> program block declaration_block declaration identifier_list type statement_list statement assignment_statement if_statement do_statement while_statement for_statement for_statement_header write_statement read_statement expression integer output_list conditional conditional_component comparator term value constant number_constant real

/*
some other shit
*/

conditional : NOT conditional
{
$$ = create_node(NOTHING, conditional, $1, $2, NULL);
}
| conditional_component AND conditional
{
$$ = create_node(NOTHING, conditional, $1, $2, $3);
}
| conditional_component OR conditional
{
$$ = create_node(NOTHING, conditional, $1, $2, $3);
}
| conditional_component
{
$$ = create_node(NOTHING, conditional, $1, NULL, NULL);
}
;


spl.y:241.72-73: error: $1 of ‘conditional’ has no declared type
$$ = create_node(NOTHING, conditional, $1, $2, NULL);
^^
spl.y:245.76-77: error: $2 of ‘conditional’ has no declared type
$$ = create_node(NOTHING, conditional, $1, $2, $3);
^^
spl.y:249.76-77: error: $2 of ‘conditional’ has no declared type
$$ = create_node(NOTHING, conditional, $1, $2, $3);

>>
>>57914180
>see nodejs
God no. Get that trash out of here.
>>
>>57914143
to be fair i think javascript should be taken more seriously, writing non critic stuff in javascript + compiling c++ modules for critical stuff/real computations sounds pretty cool, but i have to try yet
>>
Node is pretty comfy, will never understand the hate it gets.
>>
>>57914189
You don't even know why you hate it, you're just memeing to fit in.
>>
>>57914196
Javascript is horrible.
Node.js is Javascript.
Therefore, Node.js is horrible.

Seems like valid logic to me.
>>
Just a little thingy

from random import randint
while 1==1:
lowest=int(input('Enter lowest number: '))
highest=int(input('Enter highest number: '))
print()
print(randint((lowest),(highest)))
print()
>>
For someone just getting into programming, which would be the best language to learn ?
>>
>>57914196
JavaScript is hated for its inefficiency and the fact it's the most retarded implementation of OOP.
>>
>>57914214
C
>>
>>57914210
btw, it's called the uber-dice. All it does is generate a number after you enter a lowest and highest value.
>>
>>57914214
Lisp or Haskell.

C is just garbage at this point

>>57914220
kys
>>
>>57913655
In Java, in Notepad, in 10 seconds:

public boolean canMakeWord(String word, char... chars) {
return Arrays.equals(Arrays.sort(word.charArray()), Arrays.sort(chars));
}


How in the name of fuck is that supposed to be a challenge? Just check if the sorted strings are equal. We could call new String(char[]), but we might as well compare the arrays directly.

Does reddit just not know that modern languages have libraries?
>>
>>57914229
>Lisp or Haskell.
>C is just garbage at this point

please explain
>>
>>57914229
>kys
Get out of here, you stupid faggot.
>>
NODE JS CHALLENGE TIME!

Evaluate the following expressions (some may be errors!)
[]
{}
{[]}
{{}}
[] + []
[] + {}
{} + []
{} + {}
[] = []
{} = {}
[] == []
{} == {}
[] == {}
[] === []
>>
>>57914209
>>57914219
Like I said, just memeing to fit in.
>>
>>57914244
Check the results you've figured out in your head against the real answers by using this online REPL!
https://repl.it/languages/nodejs
Who knows, maybe you might consider picking it up!
>>
>>57914245
>just memeing to fit in
Please explain why my logic in >>57914209 is not valid.
I will disregard everything you say until you can do at least that.
>>
>>57914245
Fuck everyone on /dpt/, especially (you). Am I still trying to fit in?
>>
>>57914244
>[] == []
>{} == {}
>[] == {}
>[] === []

What's the problem with these evaluating to false? They're separate objects.

If you did:

var a = [];
a === a


That would be true and it makes sense.
>>
>>57914236
C is like macro-asm at best. The syntax is simple but the behaviors are not.
>>
>>57914273
>What's the problem with these evaluating to false? They're separate objects.
Why does
"abcd" == "abcd"

evaluate to true?
They're different objects.
>>
>>57914280
Strings are not objects, they're primitive values.
>>
>>57914286
That's ass backwards.
>>
File: ND4Np9c.gif (347KB, 691x827px) Image search: [Google]
ND4Np9c.gif
347KB, 691x827px
cmake or Scons?
>>
>>57914294
Plain makefiles.
>>
>>57914279
i am quite ignorant, is haskell used to build actual products? how's the effiency with functional languages?
>>
>>57914302
>is haskell used to build actual products?
No. Haskell is only used in academia.
>how's the effiency with functional languages?
Pure functional languages are quite slow compared to languages like C.
>>
>>57914302
Haskell is really fast, but couldn't compete with C without mangling the code. Not for large programs at least.
>>
>>57914280
Look up string interning and become wise.
>>
>>57914341
Ah, Java's 1 == 2 retardation.
Why would you defend that?
>>
>>57914341
>i understand that my favourite language provides wildly different results for pure expressions in arbitrary circumstances based on circumstantial optimisations
>i am wise
pick one
>>
>>57914335
That depends.
Time measurement 1:
> Time to write, test, compile and run code
In this measurement, Haskell is pretty fucking neato.

Time measurement 2:
> Time to run the code.
C has an edge here.
>>
>>57914359
No, I mean it can actually produce quite fast executable code.
Especially if you do the kind of things you'd do in an imperative lang

>prefer unboxed types
>explicitly specialize functions where possible
>use specialised containers
>flag -O3
>>
>>57911353
WPF is very easy to make a basic interface.

Load up a WPF project, drag a few buttons and labels onto the form, double click their click event and add your code to the autogen'd methods.

You could even
install-package MahApps.Metro
if that's your kind of thing, and it'll look all moderny and sheeeit.

What more could you want?
>>
>>57914356
Understanding why something is the way it is does not mean condoning it.

Also, interning is a function in Lisp too.
(intern "FOO") is perfectly legal.

>>57914350
Doesn't happen in Java.
Integer.valueOf(1) != Integer.valueOf(2),
however:
Integer.valueOf(1) == Integer.valueOf(1),
new Integer(1) != new Integer(1);

Understanding why makes one wiser.

Or are you advocating not reading the fucking docs, and not learning the quirks of your language? Because that's fucking retarded.
>>
>>57914359
>>57914371
For example, there are trivial (usually very small) cases where GHC Haskell outperforms GCC C.

http://stackoverflow.com/questions/6964392/speed-comparison-with-project-euler-c-vs-python-vs-erlang-vs-haskell/6964760#6964760
>>
>>57914180
>But JavaScript isn't just about web development,
If you seriously consider using JavaSCRIPT (i.e. the language to not be taken seriously since its creation) outside of web pages, you may kys you're selve.
>>
>>57914371
>>use specialised containers
There goes your purity.
>>
>>57914417
to a certain degree, but it really isn't much more than regular pure languages

(a, b) = (x - 1, x + 1)
requires memory allocation


the real problem is mutation, e.g. if you wanted to have a "hotlist" for the most accessed elements in some huge map
but that's only in some cases
>>
>>57914417
Fanatical purity is for waifus. Not programming languages.
>>
>>57912799
Holy C? Disgusting?
>>
>>57914445
Tell that to the Haskellfags.
>>
File: scripting.png (98KB, 518x426px) Image search: [Google]
scripting.png
98KB, 518x426px
>>
>>57914455
There are two types of Haskellfags. The academics, who just wants to see how far they can go for the fun of it, and the people who don't know any better.

If the second group did know any better, they'd be lispers, with the ability to be pure wherever they want, and filthy sluts where appropriate.
>>
>>57912033
The problem is that Windows goes into a so called 'modal loop' when you try and move/resize the window or right click the title bar. This is essentially a blocking loop outside your controll happening inside the regular message loop.
One way around it is to put the message loop in a dedicated thread which only sits there processing GetMessage.
Another is to hijack and bypass the modal loop, but that means you need to reimplement the right click menu and window move/resize logic yourself.
>>
>>57914475
>you can be pure wherever you want
Wow, so impressive.
I really wish almost every other high level language had this.
>>
>>57913914
Hahah! Looks beautifull but i cant really understand it, i am a semi-noob
What language is it?
>>
>>57914522
>high level language
Even low level languages do this.
You can write pure assembly functions.
>>
>>57914232
You should read the challenge

https://www.reddit.com/r/dailyprogrammer/comments/5go843/20161205_challenge_294_easy_rack_management_1/
>>
>>57914380
>Or are you advocating not reading the fucking docs, and not learning the quirks of your language? Because that's fucking retarded.

People are convinced that their favorite language's warts and inconsistencies are features.
>>
>>57914563
Just like you and your filthy racemixing.
Dark skin is not a feature.
>>
Is there a variant of Dijkstra's Algorithm (Shortest Path) that doesn't require the creation of 'unvisited nodes'?
>>
>>57914534
Haskell
It uses quite a few imports

An imperative version would look like this:

class Scrabble { 
string state;
void stricken(char c);
bool check(string s);
}

const std::exception e;

void Scrabble::stricken(char c) {
if (state.contains(c))
state.removeFirst(c);
else
throw 0;
}

bool check(string s) {
try {
for (char c : s)
stricken(c);
return true;
} catch (Exception e) {
return false;
}
}
>>
>>57914604
>const std::exception e;
you can remove this, I was trying to figure out C++ exceptions, I gave up and threw int instead
>>
>>57914537
>You can write pure assembly functions.
Not really.
Every instructuon modifies at least some global state (flags, registers, ip - not even nop is pure)
>>
>>57911630
Post it
>>
>>57914604
Cool! That actually helped me improve my own code by removing some useless statements.

If youre interested in the challenge btw, it has a part 2 and 3.

Part 2 is intermediate and part 3 is hard, and they all center on scrabble
>>
I downloaded AutoHotkey and found it was so cool. Then went to Autoit because I heard it was better. The syntax was much better. But I then wondered why not just use python or bash/powershell?

If I want to automate shit on the internet mostly, is python the best for the job?
>>
>>57914682
If you are a 12 year old script kiddie playing vidya then I could see how Python might be an attractive choice
>>
>>57914682
Depends on what you're familiar with, how maintainable the code needs to be, and what you're doing.

I guarantee that any popular language would be reasonably easy to sketch out whatever skiddie shit you're doing.
>>
>>57914700
>>57914693
I just want to make money automating shit.
>>
why are indians so shitty at programming, /g/? i had a class taught by one this semester and he's literally the definition of a bad programmer.
>>
>>57914713
Apply to an MSP and tell them you want to work on automation.

It's like being a sysadmin, but for 50+ different companies who all have hundreds/thousands of machines, so everything has to be scripted and deployed in an automated fashion.

MSPs are easily the best way to get your foot in the tech field door.
>>
>>57914712
https://en.wikibooks.org/wiki/Haskell
>>
>>57912420

C99 doesn't need "return 0"
>>
>>57914581

I know it's a mental illness, I just can't help it.
>>
>>57912426
main(){}
>>
>>57914824
No, but I can tell you that I made that image
>>
>>57914180
>JavaScript isn't just about web development
When your language is only used in web browsers and that one time it is used somewhere else the project fails miserably, then it is now about web development.
>>
File: umaruwp.jpg (112KB, 1920x1080px) Image search: [Google]
umaruwp.jpg
112KB, 1920x1080px
>>57912420
int main __attribute__ ((section (".text"))) = 0xC3C031;
>>
>>57915038
not portable
>>
>>57914183
doesn't work faggot
>>
>>57914970
>When your language is only used in web browsers
JavaScript is not only used in web development.
>>
>>57914720
in what way?
>>
>>57915038
Why haven't you killed yourself yet
>>
>Just got results from my first job test
>Didn't pass

Should i cry? Should i be depressed?
Tell me /dpt/
>>
>>57915076
>>JavaScript isn't just about web development
>JavaScript is not only used in web development
You're just repeating yourself now.
>>
Can someone help me with this, or alternatively, do it for me? Deadline in about 12 hours. Yes. can pay for your time/work. Thanks

http://docdro.id/LvAn8cl
>>
>>57915347
>can
yes
>will
no
>>
>>57915347
>Yes. can pay for your time/work
No way anyone is doing that shit for free. Talk money or get out.
>>
>>57914510
Windows is such a bloody mess, fuck.
>>
>>57912420
main(){}
>>
>>57915347
>857 LOC
>big program
Change instructor. Also pretty sure you could have free answers if you hasked more subtlety.
>>
>>57915347
>>>/r/
>>>/wsr/
>>>/out/
>>
>>57914417
Nigga, no. Purity isn't some academic meme where you're forbidden to interact with the world. You can have a data structure with mutability and still be pure. All that matters is that equal input means equal output and that you have referential transparency. If you want to interact with the world, well, you just have to augment your inputs and/or outputs.

Likewise, if an algorithm or data structure or something uses mutation or anything internally but it's not externally observable because everything remains pure by my standard up there, you don't gain anything by making the meaning of purity stricter and declaring that this thing is now not pure.
>>
>>57915347
literally end yourself if you can't do this in 12 hours
>>
>>57913914
>>57914093
>>57914116
doing a real good job of dispelling the puzzle-oriented programming stereotype there, Haskell nigger.
>>
>>57912203
Exactly as you said. Do not store it, store only the length.
>>
>>57915264
I'm a different poster.
>>
>>57915376
I understand, no worries.
>>57915384
I wouldn't expect anyone to do it for free (at most offer minimal guidance for free, but to be blunt, having it completed is preferable to being tutored due to time constraints). With that said, I have verified PayPal ready, very open to talking!
>>57915440
Haha if only that was an option. Yeah, it's an extensive one. Probably right about the subtlety, first time on this board so just decided to wing it.
>>57915464
Thanks, I'll try those out as well. I appreciate the reply
>>
>>57915490

Getting errors (uses an online autograder, would be content with partial credit for the tiny amount I have done but errors/warnings trip it up and it doesn't give anything) so can't really move past. Help with that itself would be tremendous, not sure what the best way to share the files would be (there's five). also have the output error. But yes, it's doable in 12 hours, you're right.
>>
//constructor
Child::Child(int i) : Parent(i) {
};


is this bad practice? are there other ways of doing this? nothing will go between the {}
>>
>>57915608
Not bad practice at all.
>>
>>57915608
yes, the 'constructor' comment is a code smell
>>
What are some recommended styles/best practices for commenting C code?
>>
>Python Programming: An Introduction to Computer Science

Is this a good book to learn programming and python? I don't want a programming job but as a hobby. I think learning the fundamentals of programming would give me a strong basis so I can apply the knowledge to other languages in the future. After that book I'm thinking of buying
>Automate the boring stuff with Python

I only want to learn from books. Weird I know but even though I stare a screen all day at home, I hate learning from it. Just so many distractions and brain fog etc.

I'm interested in making text adventures and automating tasks because I think it's cool.

Not my first time programming and I have taken a basic computer science course in high school, but forgot most of it and was never more than a beginner at python. The furthest I got was making a text adventure game and sending the exe to my friend. Don't like video tutorials beyond learning the syntax because I hate just copying code and being a code monkey. I actually want to be able to make programs by myself and solve problems.
>>
File: Capture.png (16KB, 656x486px) Image search: [Google]
Capture.png
16KB, 656x486px
>>57913914
Meanwhile in a reasonable language: a few lines of expository code and literally anyone can understand the solution.
>>
>>57915608
>is this bad practice?
yes its oop
>>
>>57915919
The one by John Zelle? Yeah, I recommend that, the book by John Guttag, and Automate the Boring Stuff.

>I hate just copying code and being a code monkey
You copy code at the start, it's like writing notes; you understand why someone else's stuff works after writing it yourself because you're forced to think about what each piece of syntax is doing.
>>
File: 4027.png (129KB, 500x374px) Image search: [Google]
4027.png
129KB, 500x374px
Why is scheme so slow?
>>
>>57915974
>Introduction to Computation and Programming Using Python

How is that different from the John Zelle one?

Thanks man. Yeah video tuts are useful, I just used one now. It all depends on the teacher. But I am just mad and weary because I followed a gamemaker tutorial before for like 15 videos. Then realised I had no idea what the fuck I was doing or why.
>>
>>57916018
Slow in execution or to program in or what?
Switch to better compiler.
>>
>spend entire day being a lazy ass
>decide to be productive before going to sleep
>end up spending four hours to implement something that's supposed to be easy

At some point I stopped thinking altogether
>>
>>57916047
>Switch to better compiler
What do you recommend?
>>
>started project in VS
>moved to Code::Blocks
>moved project out and used cmake
>then just used regular makefiles
>moved project back to VS

intellisense... is too strong...
>>
>>57916019
It isn't much different. They have similar styles of teaching but Zelle keeps it short and sweet, sticking to just covering the basics of programming in general. Guttag goes a little deeper with things like Monte Carlo simulation (google it), Machine Learning, statistics with Python, etc - things that show up in academia and the job market.

Choose between Automate the Boring Stuff and Zelle's book and then go on to Guttag's book. Michael Driscoll has a book called "Python 201" that I've been meaning to read that goes past introductory things.
>>
>>57915232
What was the test?
>>
>>57913655
>>57913914
import Data.List (permutations)

main = print $ word `elem` permutations letters
>>
>>57916327
Just realised this assumes a seven-letter word.
>>
>>57916176
Write your own.
>>
>>57916176
racket, cyclone, chicken
>>
>>57916327
>>57916373
Fix, not as elegant (contains duplications):

import Data.List (permutations, subsequences)

main = print $ elem word $ concatMap permutations $ subsequences letters
>>
>>57916176
Stalin. Look it up.
>>
>>57916529
Not even going to if there isn't a fork with a different name.
>>
>>57916638
Do what you like, broseph.

>>57916418
Just realised this is not inherently wasteful: it's optimal.
>>
>>57916638
mv stalin my-preferred-name
>>
>>57916688
nah, it'll still have that name.
and my system would be infected just by doing that move command
>>
>>57915347

Dude, it says a good programmer can do it 3 hours.

So if you put 10 hours work in you can get at least a half-decent solution (maybe with a bug or not all features included).
>>
File: Capture.png (17KB, 925x162px) Image search: [Google]
Capture.png
17KB, 925x162px
/g/ help me with my homework please
    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;
char c = ch1;
while (sc.hasNext()) {
String str = sc.nextLine();
for (int i = 0; i < str.length(); ++i) {
if (str.charAt(i) == c) {
charAccumulator++;
}
}
}
sc.close();
return charAccumulator;

}

public static boolean fileCopy(String f1, String f2) throws IOException {

File file = new File(f1);
if (!file.exists())
return false;
FileWriter fileWriter = new FileWriter(f2);
FileReader fileReader = new FileReader(f1);
Scanner sc = new Scanner(fileReader);
while (sc.hasNext()) {
fileWriter.write(sc.next());
}
fileWriter.close();
fileReader.close();
sc.close();
return true;
}
}

pic related is what they're supposed to do. I need to study and I know this is very basic stuff but it's due and I have a lot of other work to do.
>>
>>57917442
What's wrong with your code? Be more specific.
>>
File: 1474399255340.png (60KB, 300x302px) Image search: [Google]
1474399255340.png
60KB, 300x302px
>discover one of the shitty 3rd-party services that the startup I work at relies on has an API
>retard devs decided to do a JS wrapper like 3 years ago but nothing else
>write a basic read-only python one
>okay, that's the basic methods done, it's functional, now I'll make a way to narrow results using the parameters they've listed
>none of them work
>retards documented the parameters but never implemented them
>can't change to a better competitor because they're our retard CEO's buddies

Yay startups
>>
File: 1461730784652.png (15KB, 419x383px) Image search: [Google]
1461730784652.png
15KB, 419x383px
Post your programming environment

jelly???
>>
>>57917442
Here's 8, not including imports.

charCount f c b = length . filter (sameAs c) <$> readFile f
where sameAs = if b then (==) else on (==) toLower
>>
>>57917532
The fileCopy returns IOException, I'm not sure why. It's just supposed to copy a text file to another file that was provided by my professor.
>>
>>57917712
>>57917700
>>57917687
>>57917653
>>>/global/rules/10
>>
>>57917700
>>57917712
>>57917728
>>>/global/rules/10
Shut the fuck up you all
>>
>>57917442
> File file
REEEEEEEEEEE, tbqh
>>
>>57917765
File fi
>>
>>57917690
Files.copy(Paths.get(f1), new FileOutputStream(f2));


Learn to copy from StackOverflow
>>
>>57917776
Nice numbers. Almost patriotic. One less 7
>>
>>57917442
In addition to your embarrassing making convention. Writing to the file without closing it might be a thing. I don't know Java though.
>>
>>57917797
I have to use stuff I learned in class. Can you help me use filewriter/reader?
>>
>>57917442
Doh. Your program works fine. You just added a "throws" declaration to your method,
which is okay. it just means you are forcing whoever implements the method to make a try catch block,
incase the method throws any exceptions. IO is a pretty volatile thing so this is understandable.

All you need to do is add a try{ //filecopy() call } catch (IOException e) { e.printStackTrace(); }
to where-ever you're calling the method. This will make it work.

Also your method is ignoring whitespace, and i advise you look into input/outputstreams and buffers, because scanners are garbage.
>>
>>57917442
nasty
>>
>>57917849
Why would your professor ask for a sloppy hack instead of simplicity?
>>
>>57917849
Keep using filewriter, reader, but copy 4096+ bytes at a time, instead of one byte at a time. that will impress whoever is grading it
>>
>>57917849
I would recommend you submit the Haskell two-liner in defiance.

If challenged, you should breathe heavily, turn red, and repeat buzzwords such as 'elegance' and 'purity'.
>>
>>57917978
>Your program works fine.
It gives me errors. Also we aren't allowed to change the place the method is called from.
>>
>>57917635
>>
>>57918121
Are you having compile-time or run-time errors?
Paste errors here.
>>
File: 1479757106406.jpg (155KB, 800x800px) Image search: [Google]
1479757106406.jpg
155KB, 800x800px
>>57918091
Anon-kun, let me help you killing yourself
>>
?\\\
>>
>>57918121
Then remove the 'throws' and catch the exception inside the method.
>>
>>57917635
>>
>>57918303
Rust is my favorite memelang.
>>
>>57918264
I don't know how to do that.
>>
File: tegaki.png (7KB, 400x400px) Image search: [Google]
tegaki.png
7KB, 400x400px
what was the python line used to open interactive console after a certain line in the program?

>python -i script.py
only opens after the whole script is run, i want to open part-way through
>>
>>57918630
That looks like a penis.
>>
>>57918630
>i want to open part-way through
You want the interpreter to guess when it's supposed to open the console?
>>
>>57918673
No, he wants to tell it when to open the console.
>>
>>57918575
It's a good meme desu.
>>
Working on a java app that contains a dictionary and thesaurus for people to look at. Problem is the api for both that I'm using is XML rather than JSON and I'm not sure how to go about parsing it because I'm a retard. Ideally I'd want to find information about specific words and display the relevant information from the source in two boxes for users to look at, but getting it to look nice is easier than trying to get the information. Any advice /g/?
>>
File: tegaki.png (9KB, 400x400px) Image search: [Google]
tegaki.png
9KB, 400x400px
>>57918646
i dont know what youre talking about. Here's a picture with the same character with yellow lightning above him
>>57918684
>>57918673
no guessing, open console at given line
>>
File: GBzPEMQ.jpg (105KB, 640x640px) Image search: [Google]
GBzPEMQ.jpg
105KB, 640x640px
>>57918630
https://docs.python.org/3/library/code.html
>>
>>57918719
It looks like a urinating penis being hugged from behind by a penguin who is also invisible except for its arms.
>>
File: tegaki.png (13KB, 400x400px) Image search: [Google]
tegaki.png
13KB, 400x400px
>>57918731
it's a hat you see
>>
File: lewd.png (21KB, 328x278px) Image search: [Google]
lewd.png
21KB, 328x278px
>>57915347
>>
File: tegaki.png (10KB, 400x400px) Image search: [Google]
tegaki.png
10KB, 400x400px
>>57918729
thanks friendo
>>
This isn't directly related to programming so forgive me if it's in the wrong place but I'm looking for a better monospace font for working in vim in the terminal than menlo. Anyone have suggestions?
>>
I wrote a udp client / server program and for some reason every time I use a client for more than 5 minutes my internet connection goes down ( client side ) and doesnt come back for a while.

Anyone knows why the fuck this is happening ?
>>
File: tegaki.png (10KB, 400x400px) Image search: [Google]
tegaki.png
10KB, 400x400px
>>57919037
sounds like you want us to do your homework for you
>>
>>57919075
>using a non-aliased graphics software
I don't think I wanted an answer from (you) anyway.
>>
>>57918956
post actual error, it's relevant information

or post full program (imports &c.), don't make us guess everything
>>
Should I use doxygen?
>>
File: acomp.png (1MB, 934x560px) Image search: [Google]
acomp.png
1MB, 934x560px
I'd like to measure temperature with a microcontroller's Analog Comparator feature and an NTC thermistor. Basically I'd like to first charge a small capacitor via microcontroller pin and then measure how many milliseconds it takes to discharge the capacitor via the NTC resistor. The discharge time gives an approximation of the temperature.

I've already managed to write some code to deal with the charging of the capacitor. But I'm having some difficulties to get started with the analog comparator and discharge time measurement. Any hints?

Here are some macros that I've come up with:
/*
* Library include
*/
#include <avr/io.h>

/*
* Constant
*/
#define T_MEAS_PORT PORTB
#define T_MEAS_DDR DDRB
#define CAP_PIN 0

/*
* Macro
*/
#define T_meas_capchg_on() T_MEAS_DDR = T_MEAS_DDR | (1 << CAP_PIN); \
T_MEAS_PORT = T_MEAS_PORT | (1 << CAP_PIN);
#define T_meas_capchg_off() T_MEAS_DDR = T_MEAS_DDR & ~(1 << CAP_PIN); \
T_MEAS_PORT = T_MEAS_PORT & ~(1 << CAP_PIN);
>>
File: eye.png (40KB, 420x402px) Image search: [Google]
eye.png
40KB, 420x402px
>>57919075
Maybe if I had asked HOW to write my server client program you would be right, im asking about what might cause some weird problem I am currently getting. I dont know much about the underlying network issues that might occur when writing ( dumb ) networked programs.

Main culprit is that im flooding my computer with UDP packets , but the computer running the server doesnt have a problem , its the client.

>>57919118
> I
Aye
>>
For easier readability, and easier-in-future to edit, is it worth initialising 5 new 20kb textures, rather than just using one and drawing it multiple times?
>>
File: Screenshot_20161209-120428.png (82KB, 720x1280px) Image search: [Google]
Screenshot_20161209-120428.png
82KB, 720x1280px
Im working on an app that downloads text from websites and provides a tldr, tells stories, takes notes... etc.
>>
>>57915505
Wait, you DON'T understand this code?
This is basically what 1 to 1 with imperative code, except state is implicit in variables in imperative code.

gets (elem c)

getState().contains(c);
>unless b, throwError
if (!b) throw 0;

modify (delete c)
setState(getState().removeFirst(c));

check tiles word
foreach (c in word) stricken(c);

So if you don't understand imperative, and you don't understand functional, what do you understand?
>>
>>57919174
i understand how to get your mother wet
>>
>>57919150
fair point. if youre using sockets, maybe look at man pages for options? maybe theres a default timeout timer
>>57919164
http://smmry.com/
>>
>>57919152

>save 5 textures
>edit individual textures later
>changes stay on each texture
>only 5 textures stored

>save 1 texture
>have to save edits to individual textures as other textures
>combine edits with original texture
>6 textures needed
>>
>>57919178
>lolol nigger nigger i got your mom wet xd

oh, that's right, you're from reddit
>>
>>57919208
>>57919178
>>57919174
please go away, the both of you
>>
>>57919138
Why the fuck is this image 1.5MB?

What have you done?

Why did you do that?
>>
>>57914546

The solution still isn't hard.

Make a hashmap that goes from Character -> Integer.

Make some methods:
void countChar(char)
Basically, if the map does not contain the key char, put (char, 1) in the hashmap.
If it does, put (char, map.get(char) + 1) there.
This lets us build an extremely simple data warehouse. Since Data Warehousing is ENTERPRISE, and Java is ENTERPRISE, this is sure to work.

boolean useChar(char)
if the map does not contain char, we return false.
if the map contains char, then num = map.get(char);
if(0 == num) return useChar('?');
map.put(char, --num);
return;

Then we do this shit because it makes it ignor case:
word = word.toUpperCase();
tiles = tiles.toUpperCase();

for(char c :tiles.toCharArray()) {
countChar(c);
}
boolean ok = true;
for(char c : word) {
ok &= useChar(c);
}
return ok;
}

Of course, we could short circuit the loop, but I'm a lazy faggot. In fact I'm reasonably sure you can do it much easier using streams.

But building an occurrence counter and counting and detracting occurrences is not particularly hard.
>>
>>57914581
Brown elfs are best elfs you faggot.

>>57914603
And on the same board I was called a faggot for recommending AI: A Modern Approach.
>>
>>57919195
maybe this is right , the timeout could be a bit higher , I am using the DatagramSocket's default timeout timer , I think its 1000 ms for new connections but then clients ask for information from the server as fast as possible.

Ill think I should force a 15 ms sleep in the client threads and see what happens. perhaps a kind of tick rate is what I need.

Still , this entire thing makes me laugh , In trying to make a server client app I may have created a tool to dos my local connection.
>>
>>57919257
Uncompressed png. Yes, Its possible.
>>
Taking a chance here for some possible help with a php issue I'm having. I write the file parsers for our company and some of the projects I get have no file layout ,etc so I really have to wing it to get the data into the DB.

My standard procedure is to use file_get_contents() on the file and then explode() on "\n" to get all lines into an array. The issue is that there is an extra "\n" in the middle of one of the lines (my guess is because it's an address field they put a "\n" in the normal part of the address that was not removed before this file is created at the source) is an "\n" this creates an extra element in my exploded array.

Is there a good way to remove this "\n", then reattach the line it accidentally created to the line above it before I send it over to be exploded? Thanks for any ideas you guys and gals can send my way.
>>
This is the best video I've ever seen in my entire life. Those who haven't seen it yet, check it out:

https://www.youtube.com/watch?v=cbBkAdNc88w
>>
>>57919576
Terry might be bat shit crazy, but he's also a fucking genius.
>>
>>57919630
Imagine how much work he put into what is absolutely useless. Everything he wrote is of zero use to the world we live in. And yet, it's perfect and beautiful. He's a prophet and an artist.
>>
>>57919662
>useless
fuck off
>>
>>57919484
Yes split by \n only if it's at the end of a line.
>>
>>57919576
>you never get your privilege level checked
>>
File: what a time to be alive.webm (3MB, 426x426px) Image search: [Google]
what a time to be alive.webm
3MB, 426x426px
>>57911285
hey /dpt/
tell me what you love most about x86
>>
>>57919746
the -64 part
>>
>>57912487
because haskell is the best, dumbass
>>
>>57919746
cisc
>>
File: howdoidoiy.png (7KB, 929x98px) Image search: [Google]
howdoidoiy.png
7KB, 929x98px
How do I make the ArrayList slugPosition available to the entire class, not just the constructor?

I'm using java
>>
>>57912489
main = pure ()
>>
>>57919717
Well, what's it useful for?
>>
>>57919746
The tight opcode encoding,
>>
>>57919815
triangle fills
>>
>>57919781
oh gee I wonder
are you clinically retarded or what?
youi have the answer right in front of your eys
>>
>>57919796
u2 = const (const ())
instance Num () where {
(+) = u2; (*) = u2; (-) = u2;
negate = id; abs = id; signum = id;
fromInteger 0 = ()
}
>>
>>57915928
thats unreadable though
>&@@@
>>
>>57919781
>make a public field
>assign
slugPosition
to said field
>>
>+300
We need a new thread now!
>>
>>57915928
But what I gave was entirely readable, aside from the definition of run and the meaning of mapM_ (mapM_ is like foreach)

Only people who refuse to try to understand it can misunderstand it
>>
>>57919896
Are you talking about the Scrabble thing? That's a one-liner.
>>
>>57919889
New threads are at 310, at the very least.

Although it is indeed about that time.
>>
>>57919836
As soon as I asked, i tried
this.slugPosition = slugPosition;

I don't know if that's correct though, i still have some code to write until i can compile

I've previously been doing

private ArrayList<SlugPosition> slugPosition = new ArrayList<SlugPosition>();

public SlugEnemy(World world, LibPractice game, ArrayList<Vector2> slugPositionA) {

slugEnemy = slugEnemyA;

}


But this is ugly and horrible
>>
new
>>57919912
>>
>>57913914
there's so much condensed into so little code
this is why I hate haskell, it makes you actually read the code and decipher it
>>
>>57919921
See >>57916418

Totally legible.
>>
>>57919952
this is less efficient
>>
>>57919718
I looked at this for 15 seconds until I realized windows exists.

> Sent from my Windows Machine.
>>
>>57919964
Was pretty instantaneous for anything I fed it.
>>
>>57920023
try a really really long sentence against a mass of letters
>>
>>57919833
His triangle fill is pretty shit on modern hardware though.
Using barycentric coordinates and testing edge functions is much better because you can utilize those nice vector pipes and do 4-8 pixels at a time.
>>
>>57920049
It's Scrabble: it specifies seven letters in the problem description.
>>
File: Screenshot_20161209-131414.png (33KB, 720x1280px) Image search: [Google]
Screenshot_20161209-131414.png
33KB, 720x1280px
>>57919195
It's more than just a summarizer!
>>
File: Screenshot_20161209-144111.png (32KB, 720x1280px) Image search: [Google]
Screenshot_20161209-144111.png
32KB, 720x1280px
>>57920207
>>
File: Screenshot_20161209-144218.png (84KB, 720x1280px) Image search: [Google]
Screenshot_20161209-144218.png
84KB, 720x1280px
>>57921502
Thread posts: 328
Thread images: 46


[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.