[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 23
File: K&R himegoto waifux2.png (1 MB, 1000x1400) Image search: [Google]
K&R himegoto waifux2.png
1 MB, 1000x1400
old thread: >>54510936

What are you working on, /g/?
>>
>>54514945
First for D
>>
I just wrote my first interactive website!
Pls rate.

https://a.pomf.cat/dcklso.html
>>
regular expressions are so fucking complicated

does anyone understand this stuff?

re.sub('<[^>]+>', '\n',string)
re.sub(r'(.)\1{2,}', r'\1\1', u'жжж')
?????
>>
>>54515024
Include in your response an algorithm written in Haskell that iterates through N*N*N space, in the following order:
>(0,0,0)
>(1,0,0)
>...
>(MAX,0,0)
>(0,1,0)
>...
>(MAX,1,0)
>(0,2,0)
and so on.

It's totally possible but the structure of the pure version of the code is much longer, much more susceptible to bugs, and much harder to write successfully.
>>
>>54515080
You should check out the Lua string manipulation functions.

The entire Lua language is implemented in less code than Cs regex.
>>
>>54515047

virus
>>
>>54515080
>re.sub('<[^>]+>', '\n',string)
replacing any xml tag with new line
>re.sub(r'(.)\1{2,}', r'\1\1', u'жжж')
dunno
>>
>>54511266
>>54511243
consider that Haskell is based partially on the ML family of languages (SML, OCaml, F#, etc.), which have always been known for being the best choices for writing compilers (Facebook used OCaml for their Flow type checker as well as for Hack, the many-backend compiler for Haxe is OCaml, even LLVM provides official documentation for OCaml as the only language other than C++, etc.) for various reasons (algebraic data types, pattern matching, better optimized for recursion or mapping data over trees/lists)
Haskell expands on much of that with a rock-solid set of parsing libraries that make writing parsers with good error reporting ridiculously simple (Parsec or Attoparsec, for example). because of the default laziness it makes it simple to express certain types of recursive behavior. pure functions also means that it's much simpler to debug (*most of the time). finally, having lots of powerful data abstractions (functors, monads, applicatives, alternatives) defined makes it easy to write very generic operations on the code without specifically inspecting the AST or IR.
there are tons of other smaller advantages, but a lot of it ends up coming down to the fact that experts in PLT tend to go for more declarative/functional languages like Haskell (because it's closer to type theory and category theory)
>>54511150
I think Elixir (or Erlang) would be somewhere in there if we keep moving towards large distributed systems or "cloud computing". other than that probably still JS, C# or Java, C, C++
>>
File: dfsasff.jpg (43 KB, 503x427) Image search: [Google]
dfsasff.jpg
43 KB, 503x427
>learning tkinter

Oh boy I sure hope I get to type "self" some more
>>
>>54515108
The same in Caml, just translate. It's fucking easy to maintain.

let max = 2;;

let doit f a =
let rec loop a x y z =
if x > max then
a
else if y > max then
loop a (succ x) 0 0
else if z > max then
loop a x (succ y) 0
else
loop (f a x y z) x y (succ z) in
loop a 0 0 0
;;

let main () =
let f () x y z =
Printf.printf "(%d, %d, %d)" x y z;
print_newline () in
doit f ()
;;

let () = main ();;


By the way, shut up, you're ignorant.
>>
>>54515201
you shouldnt have to if that is the only reference in reach
>>
File: himegoto.webm (3 MB, 854x480) Image search: [Google]
himegoto.webm
3 MB, 854x480
>>54514983
>Pure languages discourage prototyping and iterative design just as static languages do. Haskell is not only pure but highly static.

This is an interesting argument. I'll wait on commenting about the pure aspect until your next point, but I absolutely contend that static languages (especially static typing) make iterative design easier. With dynamic typing you it's difficult to make aggressive refactors since you no longer have the promises a static language's compiler makes about correctness of code which it guarantees before the program is run. And not only that, but because the correctness is checked at runtime, static analysis of what are trivial things in a language like C++ becomes undecideable problems for a language like JavaScript.

>In order to solve a problem in Haskell you have to already know the structure of the problem in specific detail, and as such Haskell is suffocating. Iterative design in Haskell requires a lot of refactoring of type declarations.

This is kind of a more abstract issue to argue about. My opinion on the subject is that if you're a skilled Haskell developer, you will write code in a way that better provides flexibility in the event of necessary future changes (usually by guessing where the future changes are going to be). In most circumstances you don't *need* to offer type declarations in Haskell, either, though they would have to be changed quite a bit if you wrote them out between each revision. It's true that you can get better error messages when you explicitly provide type declarations.

>>54515047
10/10
>>
>>54514945
kys
>>
>>54515220
#include <stdio.h>
#include <stdint.h>

int main(void)
{
uint64_t i, j, k;
i = j = k = 0;
for(;;)
{
++i;
if (i == ~0) {j++;i=0;}
if (j == ~0) {k++;j=0;}
if (k == ~0) break;
}
return 0;
}

>hasklel
>not shit
choose one
>>
>>54515263
>My opinion on the subject is that if you're a skilled Haskell developer, you will write code in a way that better provides flexibility in the event of necessary future changes
fucking delusional, you're not smart or skilled for using haskell, in fact you're most likely the opposite
>>
>>54515337
You have to repeat your code each time you need to iterate over your set, not with functional version.
>>
>>54515263
Of course, another trapfag, this explains everything.
>>
>>54515366
maybe i would agree if i was one of the 30 autists that could read hasklel and lisp shit

>t. pajeet
>>
>>54515263
Oh, and by the way, I just saw

>>54515108

Here you go:
[(i,j,k) | j <- [0..n], k <- [0..n], i <- [0..n]]


QED.
>>
>>54515408
Sorry if you suck at programming anon. FP is beauty, Coq is the future.
>>
>>54515427
cock?
>>
>>54515436
No. Coq.
http://coq.inria.fr/
>>
>>54515419
I accidentally swapped two characters. Before you say this proves your point, C has the same kinds of nested loops, except the code is like 3 times larger. I just fucked up since the keys are next to each other.
[(i,j,k) | k <- [0..n], j <- [0..n], i <- [0..n]]


>>54515436
Automated proof assistant.
>>
>>54515449
that will be as popular as lisp and haskell
;;^/J
>>
>>54515481
It's the future. Just be patient. OCaml and Haskell grow in popularity, everyday. After that it will be Coq.
>>
>>54515507
dunno mang
scipy or some shitty (((((((((((((((((((((lisp(((((((clone)))))))))))))))
>>
File: 12754757.jpg (279 KB, 1200x1600) Image search: [Google]
12754757.jpg
279 KB, 1200x1600
Why does learning how to code turn so many people gay?
>>
>>54515540
That's fun when you're talking about languages that remove parenthesis for function calls.

You're embarrassing yourself.
>>
>>54515570
(haha (ok (whatever) (you (say)
, (friend(!)))))
>>
>>54515597
OK, you're retarded.
>>
If you're still using a language that doesn't support higher-kinded types then you should just give up and go home.
>>
>>54515568
It doesn't. it's just one retard
>>
>>54515628
make a hasklel program that says that
>>
>>54515568
They were already gay, but working in an office with 95% males just made them realise faster.

Tbh I'd rather come out in my 20s than get married, have 2 kids then realise I like cock aged 40, and end up paying child support for kids who'll never like me.
It's usually the most outwardly discriminatory who turn out to be total faggots, too.
>>
>>54515644
>If you're still using a language that doesn't support higher-kinded types then you should just give up and go home.
If you're still using a language that doesn't support dependent types then you should just give up and go home.
>>
>>54515568
I think that's just you anon
>>
>>54515653
main = putStrLn "OK, you're retarded."
>>
>>54515628
He might be the same guy who challenged me to write a Haskell program that's supposed to be next to impossible. I don't think he expected a one-liner 16 times smaller than his golfed C++ code.
>>
>>54515568
that's the question
>>tmag3ire
>>
File: smoked cheese.jpg (359 KB, 528x750) Image search: [Google]
smoked cheese.jpg
359 KB, 528x750
Is it possible to generate polygons procedurally and draw vertexes in GLSL?
>>
>>54515670
No objections from me. I was trying to be nice, hence the low bar I set.
>>
>>54515736
I like you anon.
>>
>>54515710
Of course it is.
>>
>>54515687
Have you considered maybe he just wanted a one-liner and couldn't be bothered to do it himself?
>>
>>54515752
Thank you. I like me too.
>>
>>54515763
Why would he need a Haskell expression for something so trivial? He probably doesn't even know how to give n a value in what I wrote.
>>
>>54515809
>Never attribute to malice that which is adequately explained by stupidity
>>
>>54515862
That's backwards. The correct expression is:

>Never attribute to incompetence, that which can be explained by malice.
>>
>>54515263
>just git gud
Not a valid defense.
>static typing leads to better error messages
Prelude> min 2

<interactive>:4:1:
No instance for (Ord a0) arising from a use of `min'
The type variable `a0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Note: there are several potential instances:
instance Integral a => Ord (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
instance Ord () -- Defined in `GHC.Classes'
instance (Ord a, Ord b) => Ord (a, b) -- Defined in `GHC.Classes'
...plus 23 others
In the expression: min 2
In an equation for `it': it = min 2

<interactive>:4:1:
No instance for (Show (a0 -> a0)) arising from a use of `print'
Possible fix: add an instance declaration for (Show (a0 -> a0))
In a stmt of an interactive GHCi command: print it

<interactive>:4:5:
No instance for (Num a0) arising from the literal `2'
The type variable `a0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus three others
In the first argument of `min', namely `2'
In the expression: min 2
In an equation for `it': it = min 2

Holy fucking shitballs that's a lot of text for accidentally forgetting a parameter.
>>54515809
let n = 2

Smug haskell weenie.
>>
For the person who asked about automatic dipose in C#, take a look at destructors.
>>
>>54515920
You probably think the illuminati is real too.
>>
>>54515929
No that's just an explicit error message.
>>
>>54515929
That's because you can't print a function, anon.
>>
>>54515929
Prelude> min 2

<interactive>:8:1:
No instance for (Show (a0 -> a0)) arising from a use of ‘print’
In a stmt of an interactive GHCi command: print it


At least you know that much. Now can you address your statement,
>It's totally possible but the structure of the pure version of the code is much longer, much more susceptible to bugs, and much harder to write successfully.
>>
>>54515954
No, I just don't suffer fools gladly.
>>
>>54515950
The problem with relying on destructors for cleanup in GC languages is that there are no guarantees about when they will be called. A connection could get left open for hours.
>>
>>54515888
>Functional programming doesn't divinely bestow some arcane knowledge.

I never implied causation.
>>
>>54516024
That's a problem with relying on GC for anything.
If unpredictable cleanup isn't acceptable, you shouldn't be using GC at all.
>>
>>54516063
Disposable objects is a good compromise.
>>
>>54515967
>>54515958
>it's justified
Fucking incredible. Yes it's because you can't print a curried min but holy fucking shit that's a lot of shit to parse through for a simple error message. Essentially none of that error text is fucking useful.
>>54515986
You still have to read the first block of error throwup to understand what the problem with "print it" is.

You want me to address your 1-liner? Cool you remembered Haskell's set-builder tools.
>>
>>54515920
>Everyone is out to get me

Stay tinfoil. D I R T Y B O M B
>>
>>54515954
>He actually believes this symbol was taken from some random pyramid in America.
>>
>>54516080
>Cool you remembered Haskell's set-builder tools.
Apparently you didn't.
>>
>>54516080
Sorry, I did a lot of Haskell, and that kind of problem is because you're not capable of high order code.
>>
>>54516077
So instead of "bearing the weight" of manual memory management, you just need to remember exactly what needs cleaning up from what doesn't, and then manage it anyway?

Sounds fucking gr8 m8, where do I sign up?
>>
>>54516024
>The problem with relying on destructors for cleanup in GC languages is that there are no guarantees about when they will be called.

Alright then, use "using", which is guaranteed to dispose the enclosed resource at the end of its scope.
>>
>>54516129
No, because objects that need to be managed are disposable, so you don't need to remember anything. You just have to check if the object implements the IDisposable interface.
>>
>>54516115
>smug smug smug smug
>ur inability to remember haskell's set build tools is b/c ur not a l33t haskell mathematician
>>
>>54515644
template<template<class> class F>

:^)
>>
is programming mainstream now?
>>
>>54516211
That's not what that anon was talking about.
>>
>>54516158
Good-o.

I was once bitten by some code that an intern wrote that didn't do the Java equivalent, and ended up crashing because it had so many file handles left open that it couldn't open any more files.
>>
>>54515427
Coq isn't very suited to actual programming, though.

>>54516220
Yes, it is. F has a higher kind that's similar to * -> * in Haskell.
>>
>>54516240
>Yes, it is. F has a higher kind that's similar to * -> * in Haskell.
Still not what we're talking about.

We're talking about quantification over functor.
>>
>>54516274
I was under the impression that you were talking about higher kinded types.
>>
>>54516235
>I was once bitten by some code that an intern wrote that didn't do the Java equivalent

try-with-resources is, as the kids say, "lit."
>>
>>54516217

Yes, that's why all the people who want to be special snowflakes fled to functional programming.
>>
Gotta love how angry Haskell makes a particular poster ITT.
>>
>>54516301
>"lit."
I'm not down with the kids. What does that mean?
>>
>>54516322
I fled to FP because I find it a lot more fun than OO.
>>
>>54516301
>>54516322
>Can't argue against the more simple points
>Literally can't even understand the more complicated ones
Therefore, ad hominem
>>
>>54516372
First one should point to >>54516326
>>
>>54516361

Don't take it personally, I'm just shitposting. I'm /RacketRocket/ now.

>>54516372

What are you getting at?
>>
Coursework which i have to do in C# but write it like C, because my uni doesn't want me to teach me C. It's the fucking worst.
>>
>>54516326
>he has haskell on his computer
>he hates haskell
nah not mad
>>
>>54516452
Write it like BCPL. Stick it to the man.
>>
>>54516427
I'm saying you're calling Haskell devs man babies because you don't have e a better point to make.
>>
>>54516452
That's okay, C# turns you gay anyway
>>
>>54515047
woah. your parents must be proud
>>
>>54516452
Write it like algol
#define STRING char *
#define IF if(
#define THEN ){
#define ELSE } else {
#define FI ;}
#define WHILE while (
#define DO ){
#define OD ;}
#define INT int
#define BEGIN {
#define END }
>>
>>54516479
It does, it's already sinking in.
>>
>>54516513
oops didn't realize that thread was dead
pls help?
>>
>>54516514
Try crossdressing while programming. It'll make you better at it.
>>
>>54515929
Lol haskellers btfo

>Haskell is a puzzle-oriented programming language that attracts attention of autistic-but-not-bright users that happen to like solving puzzles while programming.
>>
>>54515710
Yup:
1) Use tesselation
2) Implement a renderer in fragment shader

Read about signed distance function while you are at it, they are cool
>>
>>54516564
I now identify as a winblowsexual
>>
File: 2016-04-24-191214.jpg (124 KB, 960x544) Image search: [Google]
2016-04-24-191214.jpg
124 KB, 960x544
>when u up late working on lame stored procedures in SQL
>>
>>54516587
>programming isn't problem solving
Okay script kiddo.
>>
>>54516564
Try programming while [spoiler]cumming[/spoiler] [spoiler]hands-free[/spoiler]
>>
>>54516477

I didn't say anybody was a manbaby. I said people are special snowflakes.
>>
File: c#.png (4 KB, 353x191) Image search: [Google]
c#.png
4 KB, 353x191
>>54516452

You can write some seriously C C# if you want to.
>>
>Reading an algorithms books
>Shows how to implement a linked list with arrays
Why would you want this
>>
>>54516701
Better performance due to spatial locality.
>>
>>54516701
what exactly do you mean and what book?
>>
>>54516661
Alright. Do you disagree that it's an ad hominem attack?
>>
>>54516701
What do you mean by "linked list with arrays"? Like, the links come from an array instead of being allocated every which way on the heap?

Or by "linked list" (which is an implementation) do you really just mean "list" (which is an ADT)?
>>
>>54516701
What do you mean by a linked list with arrays? Do you mean essentially writing a linked list on a chunk of void * memory? That's pretty fucking useful man.

Here's a practical application
>http://linux.die.net/man/2/mmap
>>
>>54516709
Just seems like it defeats the purpose of a linked list since it's not easy to grow and shrink
>>54516718
>>54516724
>>54516739
https://shodan.me/books/Algorithms/Algorithms_in_C_-_Sedgewick.pdf
Page 23 of this book, I'm not sure how to explain it concisely because the concept itself is a bit confusing (to me at least)
>>
I knew it. Op is a fag. It's a fact.

Inductive Sexuality :=
| Fag
| Straight.

Check Sexuality.

Inductive Poster :=
| Op
| NotOp.

Check Poster.

Definition getSexuality : Poster -> Sexuality :=
fun _ => Fag.

Check getSexuality.

Theorem opIsAFag : forall p : Poster, p = Op -> getSexuality p = Fag.
auto.
Qed.
>>
In Python I am reading piped input from a subprocess which is piping me five JPEG images one after the other.

How can I split that pipe output into its separate files? If I write all the pipe output to a file I get a single JPEG that seems to contain the data of all 5 but only shows up as a single picture.
>>
>>54516780
It's still easy to grow and shrink. Anyways being able to store it on an array is nice. You can mmap it to shared memory, a file, or something.
>>
>>54516780
If the size changes, you don't necessarily have to realloc the whole thing though, you could store it in a few blocks.

In many cases, a hybrid linked-list/array is better than either pure option.
>>
>>54516867
should the solution be in python itself? did you try xargs instead?
>>
>>54516867
Can you modify the subprocess to pipe in the images in a python list format?
>>
File: 2sweaty.jpg (15 KB, 300x300) Image search: [Google]
2sweaty.jpg
15 KB, 300x300
>>54516835
A corollary of this is that literally everyone is a faggot. I... had no idea...

>mfw
>>
>>54514945
fuck off this programming fag meme
>>
>>54516722

No.
>>
>>54516545
a-anyone..?
>>
>>54517257
Jeg forstår ikke problemet ditt. Kan du skrive det på norsk?
>>
>>54517303
Nei, men jeg liker dette språket
>>
>>54517303
How the fuck did you know he spoke Norwegian?
>>
>>54517341
I don't speak Norwegian
>>
>>54516835
>>54517182
It looks like you were setting up to eliminate in `getSexuality' so that `Op` would give `Fag' and `NotOp`, `Straight', but you forgot...
>>
What's the go-to source for learning Haskell?
>>
>>54517355
What did I just read then?
>>
>>54515080
\1 is a backreference, it matches the first element captured, in this case (.), which matches any character.
>>
>>54517368
He said he couldn't understand my problem, and asked for me to write it in Norwegian.
I said I can't, although I like Norwegian.
>>
>>54517385
I see
>>
>>54517257
std::make_shared
is almost guaranteed to be safe. You don't want to pass an existing pointer to shared_ptr -- it's actually very hard to, because it potentially can break the safety shared_ptr is supposed to guarantee. Instead, you should change some_method to return a shared_ptr.

For referencing your dog, you don't want to do
Dog->paw
, since Dog is the name of your class. Instead refer to your particular instance of Dog using your variable, dog.

Hope this helps.

>>54517358
I'm not the original guy, I just read the proof and noticed that.

>>54517234
Well, do you still feel the way you originally did when you were talking about Haskell? If so, I guess this isn't very productive.
>>
>>54517450
>Well, do you still feel the way you originally did when you were talking about Haskell?

That it's for special snowflakes? Yes. I admit this is an ad hom, then again, I was never invited to address the points, anyway.

It was more of a sidebar than an argument, because as Stefan Molyneux says, "not an argument."
>>
>>54517046

Nah, it's coming from FFMPEG, so I have to just take what it gives me.

>>54517001

I'm on Windows m8
>>
>>54517512
It's called cygwin
>>
>>54517512
Well if it's just outputting an array of jpeg files with no formatting or anything, you're going to have to write some bitfiddly shit to convert it into a format that's more convenient to use.

Look up interfacing with python. You'll probably also need to learn how jpeg files are structured.
>>
>>54517525
I think you mean Gentoo
>>
>>54517477
Alright, I can understand that. Anyway, I hope we'll get to talk again sometime - I enjoy debating with people, but sometimes I get a little harsh. I never try IRL because years ago I learned it usually ends up with people disliking each other. I hope there's no hard feelings.
>>
>>54517554
You can't run a marathon while you're learning to crawl.
>>
>>54517575
But you can crawl a marathon, can't you? There aint shit stopping you from crawling 26 miles
>>
>>54516835
nice Coq
>>54517572
people only end up disliking each other when they disagree if they're being faggots about it
the part that disagreeing makes difficult is getting to like them in the first place
>>
>>54517572
>I never try IRL because years ago I learned it usually ends up with people disliking each other.

I do it all the time. If people don't like "shall not be infringed" then we probably won't be a good match as friends anyway.
>>
>>54517602
>shall not be infringed
If only. We need to repeal all firearms legislation.
>>
>trying to find information about Xorshift
>keep getting linked to fucking mirrors of Wikipedia
Augh.
>>
>>54517686
https://github.com/davidbau/xsrand
http://www.arklyffe.com/main/2010/08/29/xorshift-pseudorandom-number-generator/
http://www.javamex.com/tutorials/random_numbers/xorshift.shtml
http://excamera.com/sphinx/article-xorshift.html
>>
>>54517686
http://xoroshiro.di.unimi.it/
>>
>>54517450
I'm using a library for that method though, it returns a raw pointer and I can't change it for obvious reasons.

And yeah, that Dog->paw was a good typo. I'm referencing the paw using my dog instance.
>>
Programming is LITERALLY impossible
You guys are all faking it
>>
>>54517809
You've caught us
Pack it in lads, no more threads from here on out
>>
>>54517823
>lads
Check your privilege.
>>
template <typename T>
std::string to_string(T value)
{
std::ostringstream os ;
os << value ;
return os.str() ;
}


Is it legal to marry a c++ function because this one has everything I've ever wanted in a companion.
>>
>>54517809
keep telling yourself that millennial babby
>>
>>54517683
>We need to repeal all firearms legislation.

I love you.
>>
>>54517840
>dat RAII
>>
>>54517761
Well, you can't assign to a shared_ptr from an existing pointer, but you can construct it as already managed by doing
std::shared_ptr<Dog>(dog)
, I believe.
>>
>>54517839
oh, you're right, programming is literally impossible

for females
>>
>>54517877
Nah, (most) men can't do it because it's an inherently feminine activity.
>>
>>54517897
kys

a lot of men can't do it (properly)

the vast majority of women can't do it
>>
programming (not web dev) is masculine as fuck, that's why most women are not interested in it at all (except the ones that delusionally believe that it's an easy way to get jew bucks), and it's why the right kind of autists are good at programming, because they have extreme male brains

stop this forced trap fag meme and kill yourself
>>
>>54517965
I programmed so much that I turned into a woman.
>>
File: Capture.png (66 KB, 869x585) Image search: [Google]
Capture.png
66 KB, 869x585
wtf
>>
How many people here do programming as a hobby and not as a career?
>>
>>54518006
Here
I have no clue what I'm doing though
>>
>>54518006
I was under the impression that most people here do it as a hobby
>>
>>54517993
newposts = active[:]
>>
>>54518006
I've used it a bit at my IT Security position
Other than that, I've mostly been self-teaching
>>
>>54518006
I do it as a fetish.
>>
>>54518043
fucking cancerous python
>>
>>54518043
based. thanks

why is that necessary though?
>>
>>54518006
me, I've passed a Java class and intro to CS class with an A, understood the concepts of basic OOP stuff no problem, started self-teaching python and everything is going smoothly etc etc yet I still never understand whats going on in these threads. I think i'm just retarded.
>>
>>54518063
>what is a pointer
>>
>>54518063
Er det et dårlig språk?
>>
>>54518079
>active is a pointer
>newposts is a pointer
>newposts=active fails
kys
>>
File: 1431892827541.jpg (957 KB, 1800x1198) Image search: [Google]
1431892827541.jpg
957 KB, 1800x1198
I want to manually set indices of a list even if that index is outside of how big the list previously was
Is there a direct way to do this in C#?
>>
>>54518070
your way was putting the pointer into the new variable not the contents of the list, so as you were modifying active you were also modifying newposts, by using the slice (or whtever it is called) notation you make a copy
>>
>>54518079
>pointers in python
>>
>>54518101
Why? I feel like you don't want a list.
>>
>>54518095
det är ett av de absolut sämsta språken som finns överhuvudtaget. det är i klass med ruby, javascript och php.
>>
>>54518101
have you considered using an array?
>>
>>54518104
ok, that makes sense. thanks anon
>>
>>54518117
Håll käften
>>
>>54518154
din mamma
>>
Wer /Deutsch/ hier
>>
>>54518097
what do you mean by an assingment failing?

>>54518107
some things are passed by reference some by value, python is a weakly typed language meant to be simple, that comes at the trade off that you need to know some special cases, such as what it means to assign a list to a new variable, this isn't ideal but some people tolerate it for the sake of simplicity, its a matter of preference
>>
>>54518117
Liker du Scheme eller Clojure?
>>
>>54518101
Have you considered using a map?
>>
>>54518168
how are programming related jobs in Germany?
>>
>>54518234
>>54518143
Eeh, you're right, I should be using an array. I was just being a lazy cunt with my implementation desu
>>
>>54518006
im too autistic to get a job.

maybe someday
>>
>>54518242
Sehr gut, danke. Ich esse Schokolade zum Frühstück.
>>
>>54518168
Ich bin Deutsch. Genieße ich meine Lederhose, Techno-Musik und Scat porn. Das sind super tolle!
>>
>>54518242
Ich weiss nicht, ich liebe in Amerika und habe an der Uni Deutsch gelernt B)
>>54518283
Noice
>>
>>54518283
Arbeit macht frei
>>
>>54518255
Csharts everyone
>>
>>54518298
Außerdem trinke ich Bier am Freitag mit meinem Vorgesetzten.
>>
/dpt/ java pleb here

I'm trying to initialize an object through a switch statement, but oddly the object doesn't initialize it properly inside the switch

If I initialize the object outside the switch, it works fine. The switch is inside a do-while loop, object is declared outside the switch
Using set methods for the object inside the case also doesn't work

What could I be missing?
>>
>meine Datenstrukturen
>meine Algorithmen
>>
>>54518333
POST THE FUCKING CODE YOU SCRUB
>>
>>54518333
Post code.
>>
>>54518331
why is this a thing in programming shops, drinking beer on fridays, who the hell even drinks beer voluntarily
>>
>>54518342
top kek
>>
>>54518342
Mein Gott!
>>
>>54518333
in java you can't initialize stuff inside of functions and expect to use it outside of that function
you have to declare stuff first, outside of it

I think that's what you're trying to do, yeah?
>>
>>54518367
Gesundheit
>>
>>54518331
Super, jede Woche?
>dgw 20
>>
>>54518360
Hast du deutsches Bier geschmeckt?
>>
>>54518398
Nein, aber Ich haben guten tingen um deren hören.
>>
>>54518348
>>54518350
public static void main(String[] args){

Scanner input = new Scanner(System.in);
ChainedTable<Integer, Customer> pTable = new ChainedTable<Integer, Customer>(10);

Customer cust = new Customer();
int menuInput;
String name;
String address;
int phoneNumber;
//initialize menu
String menu = "1 - Enter a new customer\n";
menu += "2 - Retrieve Customer's info\n";
menu += "3 - Remove a customer from the table\n";
menu += "4 - Exit\n";


do{
System.out.println(menu);

menuInput = input.nextInt();

switch(menuInput){


case 1:

System.out.println("Enter the customer's name");
name = input.nextLine();
input.next();
System.out.println("Enter the customer's address");
address = input.nextLine();
input.next();
System.out.println("Enter the customer's phone number" );
phoneNumber = input.nextInt();

cust.setAddress(address);
cust.setName(name);
cust.setPhone(phoneNumber);
pTable.put(phoneNumber, cust);
System.out.println(cust);
System.out.println(pTable.get(phoneNumber));
break;


Object initialized outside of case prints everything OK (customer info)
Object initialized inside case/switch doesn't print customer name/address (object isn't initialized properly)

Excuse my plebness, I'm really just getting used with java
>>
>>54518395
Ja.
>>
File: file_3_3.jpg (390 KB, 3072x2048) Image search: [Google]
file_3_3.jpg
390 KB, 3072x2048
Just a reminder.
>>
File: CQD74IGWcAA1-_2.jpg (21 KB, 296x449) Image search: [Google]
CQD74IGWcAA1-_2.jpg
21 KB, 296x449
>>
>>54518458
>>54518460
Weine mehr.
>>
>>54518458
[clapping intensifies]
>>
>>54518006
Started as a hobby when I was 9. In high school I realized I could make a career out of it, so that's what I'm doing.

>>54518053
u kno it bb

>>54518421
What's the object in question? cust? And what's the whole do while loop? It might be important. Where are you trying to initialize cust when you put it inside the case?

There isn't enough information you're giving us.
>>
>>54515201
you mean
>learning python
>>
>>54516680
>casting what you pass to free
what
the
fuck
>>>>IntPtr
>>
File: Untitled.png (35 KB, 1001x565) Image search: [Google]
Untitled.png
35 KB, 1001x565
>>54518421
what >>54518536 said, need more info

switching case based on input is working as expected
>>
>>54518747

It's the nature of the interop. Free wants an IntPtr, not int*.
>>
>>54518791
absolutely horrifying
how this got past design review i have no idea
>>
>>54518006
Still in school and haven't gotten a job yet, so it's still a hobby.
>>
>>54518805

It's not the fault of C#
>>
>>54518823
??? oh
>>
>>54518841

No, it's your fault.
>>
>>54518823
>C# interop being retarded
>Not up to C# to stop its own interop being retarded

Are you waiting for team america to help you?
>>
>>54518823
>Objects are eligible for garbage collection once they become unreachable.
>The memory won't be freed unless the garbage collector believes you are running out of memory.

To think I almost believed the C# meme.

How is a memory leak that soaks up all of your available RAM before freeing any better than one that never actually stops?
If it can't even prevent heap exhaustion, why fucking bother?
>>
I need help badly and have no clue what the fuck I'm doing.
I've got a string coming back in the cookies of a web application and I need to decrypt that string using PBKDF2 decryption given a passphrase, salt and HMAC authorization code. How do I combine all of this shit in C# to get out the original decrypted session ID in string form?

string session: "a jumble of shit data"
passphrase: "a secret code that I'm given to properly decrypt"
salt: "also given to me to properly decrypt"
HMAC "hashed key also given to me"

output: The non-encrypted session key.
>>
I'm new to python. This code wont execute.
#!/usr/bin/python

#Pick a rule
rulepick = input("Pick a rule from 1, 2, or 3. \n 1. y = 5x+2 \n 2. y = x+3/2 \n 3. y = 10x+1/9 \n")

#---------------Applying and Displaying Coordinates----------------
if rulepick in ["1"]:
x = input("choose a number for x 1-100 \n")
y = x*5+2
print ("("x","y")")
exit()

if rulepick in ["2"]:
x = input("choose a number for x 1-100 \n")
y = x+3/2
print ("("x","y")")
exit()

if rulepick in ["3"]:
x = input("choose a number for x 1-100 \n")
y = x*10+1/9
print ("("x","y")")
exit()
#-------------------------------------------------------------------

#Informing user of unrecognized command and aborting.
if else:
print("Unrecognized command. Enter 1, 2, or 3 when choosing a rule. Exiting.")
exit()
>>
>>54519190
Did you try running it?
>>
>>54519190

What's the error?
>>
File: fail.png (3 KB, 351x18) Image search: [Google]
fail.png
3 KB, 351x18
>>54519201
>>54519214
>>
File: 1462475906167.gif (183 KB, 500x250) Image search: [Google]
1462475906167.gif
183 KB, 500x250
>>54514945
I'm working on a reverse engineering tool for linux that'll be equivalent of Cheat Engine in winshit. It'll contain many AND MANY useful tools just like the CE. You can check it at here:

https://github.com/korcankaraokcu/PINCE

The only language I knew before starting this project was assembly(x86-64, AS(actionscript) 1,2 and 3, MIPS). A few months ago I noticed that there's no equivalent of CE in linux and the security implementations for games are very weak(even with just gdb you can hack into many games, try for yourself anon!) manned up and challenged myself with this utility program. I put a time limit of 2 years for myself to finish this program without any prior knowledge of python, pyqt, gdb and linux itself(just freshly installed kubuntu a few months ago). The only thing I hate doing is GUI, designing GUI is fun but dealing with the concurrency and threading problems of pyqt is cancerous, it's not even about brain storming, just prior experience and knowledge, I just noticed that I simply hate OOP after starting this project, I wish I had someone experienced helping me with that...
>mfw still didn't lose hype
>>
>>54519292
Is Python in your /usr/bin directory
Do you even have it installed
>>
>>54519297
*then manned up, sorry for typo
>>
>>54519301
its installed on Linux by default.
And yes.
>>
File: Untitled.png (3 KB, 327x64) Image search: [Google]
Untitled.png
3 KB, 327x64
how?
if c isn't an empty string, how the fuck can it not find the last element?
>>
>>54519327
> c[len(c)]

that's not the last element anon
>>
>>54519369
even c[-1] was out of bounds
I don't get it.
>>
>>54519391
i cant help you if you dont post the rest of your code
>>
>>54519427
It's no big deal now. I reordered my while loop and accomplished the same thing.
Thanks
>>
>>54519153

You mustn't be using it right if that's becoming a problem.
>>
Haskell:

[(a,b,c) | b <- [1..], a <- [1..b], let c = (floor . sqrt . fromInteger) (a^2+b^2), a^2+b^2==c^2]


This is an infinite list of all Pythagorean triples that runs in quadratic time to the size of the legs.
>>
>>54519153
It's not a memory leak. This is how a properly written batch garbage collector functions. You're an idiot.

The more the garbage collector frees at once, the more efficient the GC is. So, a batch GC tries to accumulate as much to clean as it can before doing it all at once. If some other application needs memory, the GC detects this and starts a GC pass early. It essentially never causes issues with other applications.

>>54519297
That's really cool, anon.
>>
>>54519488
Muh lazy evaluated sequence
>>
>>54519327
>>54519369
>>54519448
I'm trying to parse a json file in python and it's a total fucking nightmare

I have to match names up with other names and values and nothing is in order so i have to make multiple passes over it
f = open("file.txt","r")
newfile = open("JSON_COEF.csv","w")
keys = {}
c = f.readline()

while c != '':
if c == ' },\n':
lastpos = f.tell()
if '"lmname":' in c:
curpos = f.tell()
lmname = c.split('"')[-2]
f.seek(lastpos)
c = f.readline()
jsname = c.split('"')[-2]
keys[jsname] = lmname
f.seek(curpos)
c = f.readline()

print keys
f.seek(0)
c = f.readline()
while c != '':
if '"coefficients": [' in c:
c = f.readline()
while '],' not in c:
newfile.write(c.split(' ')[-1][0:-1])
c = f.readline()

newfile.write(',')

while '}' not in c:
c = f.readline()
if '"field":' in c:
c = c.split('"')
newfile.write(c[-2])
newfile.write(',')
newfile.write(keys[c[-2]])
newfile.write('\n')
c = f.readline()
f.close()
newfile.close()
>>
>>54519626
Thank you anon! :D

>>54519788
Why don't you try regular expression? You could get rid of a lot of loops and checks with it.
>>
>>54519788
Is it a json file or a csv file? Also why dont you just use the json package?
>>
>>54519857
i can't into regular expressions
>>54519865
I am extracting stuff from a json and putting it in a CSV because i need to make a diff of some names and coefficients from different files
>>
>>54519788
use the json package

import json

with open("file.txt", "r") as file:
data = json.load(file)
print data
>>
>>54519910
i had no idea that existed.
i don't really have a problem getting the json data, but i might use this later.
>>
>>54519488
Could be better. Learn Euclid's algorithm for computing pythagorean triples.

Note that m + n has to be odd and m has to be greater than n for the algorithm to avoid generating duplicates. The wikipedia article doesn't mention that bit for some reason. Probably because wikipedia is a legitimate source.

.t number theory schemefag
>>
>>54519943
well add that bit
>>
File: 0045 - f3MdulY.jpg (450 KB, 1920x1200) Image search: [Google]
0045 - f3MdulY.jpg
450 KB, 1920x1200
I'm probably going to get a lot of shit for this but...

What programming language should I start with? as of now I can't really right a functional program in anything except Scratch and maybe RobotC (very little). I learned a bit of javascript but haven't started on any more serious programming languages. I decided to do Learn lisp the hard way, using SBCL, and the sicp (aka fell for the meme) , but I'm reconsidering starting with Python.

What is your opinion?
>>
>>54520004
C
It's not as bad as people say.

Python is good if you just want to make stuff or if you have task you need to do quickly, but it also teaches you bad habits

also fuck using whitespace delimiting. i never realized how much i hated it until i came back to python.
>>
>>54520004
>>54520079 is pretty on the money. I'd like to add Java, as verbose and pajeet-tier as it may be, since it really helped me understand the whole idea of OOP and the class/object relationship, which I didn't clearly get with Python.

I recommend picking one language and stick with it. Doesn't matter if it's C, Python, Java, Lisp, Haskell, whatever - once you get your first language solidly under your belt, it'll make learning other languages that much easier.
>>
>>54520004
Learn List the Hard Way is a really awful site, it's recommended that you avoid it.
>>
>>54519897
There is a first time for everything, only if you have enough time ofc lel. I'd say spending time for learning regular expressions is extremely useful and time saving for future projects. The place where I learned was python docs, people overlook docs most of the time thinking "who's going to read all that stuff now?" But if you can spare a few hours, you can learn it very easily.

A few examples from my code:
https://github.com/korcankaraokcu/PINCE/blob/master/GDB_Engine.py

\d+\s*Thread\s*--->New Thread 0x7fab41ffb700
\d+\s*Thread\s*--->1 Thread
\\t0x[0-9a-fA-F]+--->\t0x31
:\\t[0-9a-fA-F-,]+--->:\t1,3961517377359369e-309
<.+>:\\t---><_start+4>:\t

Here's a mini guide:
\d stands for digit characters
\d+ means 1 or more characters matching, \d* means 0 or more
\s means any whitespace(tabs, newlines etc.)
[abc] means any of the characters a,b,c is accepted
[0-9a-fA-F-,] means that characters between 0-9,a-f,A-F and - and , are accepted
. means ANYTHING, this is a bit greedy but does the work
\ is the escape character, if your string contains something like this "\s" you should search it with "\\s" instead since \s stands for whitespace characters.
Hope it helps, never late for anything!

>>54520004
Well, it's about how passionate you are and what your purpose of learning is. For instance, I started with assembly and now trying to get out my shell with shittons of trial error. Just don't afraid of doing mistakes and you'll be fine anon. Don't call the memes but for the learning purpose I can tell this: If you are interested in how computers and operating systems work you should start with C, C++ or assembly(espically if you are interested in operating systems) like me, but if you like to get your work done quickly languages like python is the way to go.
>>
>>54520004

learn C and the 3 file format of header, main, and source files and you got some good shit.
>>
>>54519965
What? You're not interested in writing the best program possible?
(use srfi-1)
(define (uniqueness-criterion pair)
(and (> (car pair) (cdr pair)) (odd? (+ (car pair) (cdr pair)))))
(define (genpairs m)
(list-tabulate (- m 1) (lambda (x) (cons m (+ x 1)))))
(define (flatten alist)
(fold append '() alist))
(define (euclid pair)
(let ((m (car pair)) (n (cdr pair)))
(list (- (* m m) (* n n)) (* 2 m n) (+ (* m m) (* n n)))))
(define (triples m)
(reverse (map euclid
(filter uniqueness-criterion
(flatten (map genpairs (list-tabulate m (lambda (x) (+ x 1)))))))))

This code generates no duplicates or trivial Pythagorean triples. Trivial pythagorean triples being ones like (6,8,10).
Thread replies: 255
Thread images: 23

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.