[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: 320
Thread images: 31

File: john-mccarthy.png (413KB, 542x506px) Image search: [Google]
john-mccarthy.png
413KB, 542x506px
What are you working on, /g/?

Old thread: >>60025489
>>
>>60032063
Lisp is the most powerful programming language.
>>
nth for C, still the very best language
>>
Is that the guy who invented Minecraft?
>>
A neural network to distinguish loli images from the junk that /b/ spams
>>
File: idris_book.png (238KB, 1553x958px) Image search: [Google]
idris_book.png
238KB, 1553x958px
I've finally got a nice pdf version of the Idris book, if anyone's interested: http://rgho.st/7LW4nYnJx .
>>
>>60032103
Is Idris comfy?
>>
>>60032105
Can't say yet, it looks like Haskell but more autistic.
>>
C was a ______
>>
>>60032103
Why would I use Idris over Haskell?
>>
>>60032131
Dependent types.
>>
nth for how is your day going /dpt/
>>
>>60032126
Mistake
>>
functional programming is a meme
>>
>>60032126
great in 1972 but is dated.
>>
>>60032126
mistake.
>>
>>60032126
language replaced by rust.
>>
>>60032147
I feel comfy after switch back to a light color scheme.
>>
>>60032126

mistake
>>
>>60032131
there are more real life jobs in Idris.

he, he, he.
>>
>>60032126
big mistake
>>
File: 1487413306014.png (383KB, 611x720px) Image search: [Google]
1487413306014.png
383KB, 611x720px
>>60032126
Miracle.
>>
>>60032126
Mistake
>>
>>60032178
>>60032196
>>60032164
Function overloading is not supported
>>
>>60032126
a short-sighted and unwise decision whose devastating effects we very well may never fully recover from
>>
>>60032126
Marvel.
>>
>>60032101
you'd do a better job, making NN that recognizes IR porn on /pol/

>>60032126
>C
>was
is still a ________
>>
>>60032126
god's mistake
>>
>>60032201
I prefer MILFs so I'll stay with Haskell.
>>
>>60032126
mistake.
>>
>>60032235

Make an NN that recognizes qt black women on /pol/ and pings me.

That would be fun.
>>
Reminder to start your day with a couple of algorithm exercises and a glass of water.
>>
>>60032249
Africa was a ____
>>
File: 1453306116180.png (58KB, 313x196px) Image search: [Google]
1453306116180.png
58KB, 313x196px
>>60032219
Why is it when people bring up features missing from C, they bring up the most retarded and useless ones?
Namespaces and function overloading are particularly popular ones for some reason. You fucking idiots should learn what an ABI and a symbol is, and then shut the hell up. I'm quite a fan of C, and I'll admit that there are things missing and has its share of legacy warts, but fucking bring up actually worth giving a shit about.

Even then, C actually DOES support function overloading through _Generic, but you have to rename the symbol something else.
>>
>>60032284
Of course anon.
>>
>>60032273
>bring up actually
bring up something actually*
>>
>defending C in 2017
I'm so sorry you had to see this /dpt/
>>
>>60032299
Typical code monkey.
>>
>>60032273
TRiGGERED
>>
File: 1489031866201.jpg (44KB, 538x491px) Image search: [Google]
1489031866201.jpg
44KB, 538x491px
>tfw Jai gets released and we get a C and C++ replacement with the introspective power of LISP with a focus on speed
>>
>>60032330
>a C and C++ replacement
Its a side-step at the most.
The syntax is ass and its gonna need a complete overhaul from all the shit i saw on his streams.
>>
>>60032342
>Who are you quoting?
>>
>>60032350
>>Who are you double quoting?
>>
Win32 programming is slowly destroying my soul.
>>
>>60032357
Come on a POSIX os anon.
>>
>>60032361
>Who
areyou
quoting?
>>
>>60032363
I made the mistake of making a GUI application.
I've tried raw X before, it was even more painful.
>>
>>60032376
So why don't you just use Qt?
>>
>>60032376
You can use VS + C# on the NT os. It's the best and it will work on GNU/Linux with mono.
>>
>>60032363
POSIX isnt much better 2bh.
Replace the verbosity and insane design choices for pure tedium
>>
>>60032346
>Its a side-step at the most.
Nah, the metaprogramming abilities are great and there is a real clamor among graphic and game devs for something better than dealing painfully with custom metaprogramming tools for C or dealing with C++ """features""".
Doesn't hurt that he understands the importance of a strong core library either with all his hatred of STB/STL/Boost.
>The syntax is ass
He says the syntax is only temporary and will get a complete overhaul before release pretty much every time it's brought up.
>>
>>60032391
It ain't Lisp, so it's shit.
>>
>>60032342
>I don't like when quotes are misused
quoting you btw
>>
>>60032376
Electron?
>>
>>60032384
Well, the initial version of the application did use Qt. It also bundeled a Ruby interpreter and linked Qt statically.

>>60032385
F U N
>>
>>60032272

great continent when it was colonized.
>>
>>60032400
Lisp Hispters would say Lisp was shit as well if it became a popular language.
>>
File: 1462970641659.png (754KB, 736x715px) Image search: [Google]
1462970641659.png
754KB, 736x715px
>>60032330
>Not planned
>Jai will not have:
> Smart pointers
> Templates or template metaprogramming
> RAII
> Constructors and destructors
> Subtype polymorphism
> Exceptions
> References
> A virtual machine (at least, not usually—see below)
> A preprocessor (at least, not one resembling C’s—see below)
> Header files
I remain sceptical of the language, but I will admit that Jonathan Blow has his head in the right place.
>>
>>60032427
implying Jai will ever be popular
>>
>unironically giving (you)s to this WAYQ with an autistic twist gimmick
/dpt/ stop.
It's like baiting /v/ with their bad taste in music.
>>
>>60032438
>What are you quogramming?
>>
>>60032385
>GNU/Linux with mono
Please don't. It's like injecting yourself with cancer.
>>
>>60032428
>> A preprocessor
ancient poo.

>header files
>a feature, not a blight
>>
>>60032453
Read the first line, idiot.
>Not
>>
>>60032467
gomen~
>>
>>60032484
https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md
The first result on google for "Jai programming language".
Now can you please kill yourself.
>>
>>60032484
>>60032493
>Who are you quoting?
>>
>>60032493
Can you specifically reference the statements in question, for clarity?
>>
>>60032428
>Smart pointers
Well yeah, it won't have the bugs-relabeled-features that make them a necessity in the first place.
>Templates or template metaprogramming
>RAII
Case in point.
Hell he even showed recently that his easy-to-use metaprogramming functionality gives you more than RAII ever did.
He shows off a couple of bits here: https://www.youtube.com/watch?v=gWv_vUgbmug#t=25m21s
>Constructors and destructors
If you want to bundle allocation and assignment like a Sepples Pajeet you can do so manually.
>Exceptions
Great. Exceptions are not something you want in performance critical software.
>Header files
Pretty sure he doesn't use header files in the C sense.
>I remain sceptical of the language, but I will admit that Jonathan Blow has his head in the right place.
That's a fine position to take. I'm no language evangelist myself, just hyped that he seems to value the things I value and may make fun programming viable again.
>>
>>60032499
>>Who are you quoting?
>Whose quotes are you quoting?
>>
What data structure is a quoting
>>
>>60032509
proceed to
>>60032467
>>
Express your day so far, or life, or current feelings, as a type signature
>>
>>60032519
'(who are you quoting)
>>
>>60032519
http://clhs.lisp.se/Body/s_quote.htm
>>
>>60032509
I actually think that all of those features missing from Jai are a good thing. I realise that my post didn't make that clear.
Blow actually seems to understand C, and seems to realise that simplicity is best.
>>
>>60032567
>features missing
>good thing
>>
Any good websites/youtube channels to start studying a programming language? Python preferred but any would be fine. I already know C.
>>
>>60032567
Ah right. Yeah I can see now re-reading your post that you meant the opposite.
>>60032579
Most of those "features" are either bad ideas, badly implemented ideas or exist only to solve issues that exist only due to earlier bad ideas.
It's like complaining that Smalltalk, OCaml or somesuch is bad because it doesn't have C++'s retarded OO ideas.
>>
>>60032579
Yes. Features missing _is_ a good thing. C prides themselves on lack of features and it's part of the reason it's so popular. Blow seems to understand that.
Just piling more unnecessary crap into a language isn't going to make it better.
>>
>>60032633
>themselves
itself*
>>
>>60032619
>>60032633
Neo-luddism at its finest.
>>
https://strawpoll.com/5w2dazg
>>
>writing small program to pick random songs form my music folder
>some songs have same name (Untitled for example)
>want to rename song to Untitled 1, Untitled 2 in that case

Does anyone have any idea how to cleanly solve this? I've been trying for like 30 minutes, but my not programmer brain can't handle it. Here's my general approach:

max_size = 1000
all_songs = get_songs_from_folder()

current_size = 0
while current_size < max_size:
random_song = get_random(all_songs)
current_size = current_size + size_of(random_song)

# overwriting can happen here
copy(random_song, new_songs_directory)


My not so pretty solution involved checking if there is already a song with the same name in the directory, and if it is, name it "Untitled 2" with a global counter. Eventually I'd end up with

>Untitled
>Untitled 1
>Sample
>Sample 2
>Test
>Test 3
>Test 4

Because my counter is global. Any advice?
>>
>>60032063

I'll take a bucket of 12 herbs and spices, and two large fries.
>>
If you guys aren't going to help, can you direct me to somewhere that can just explain to me who exactly you are quoting?
>>
>>60032654
>What are you talking about, anon?
>>
>>60032640
>Fucking luddites who don't want pectoral fins-adapted bike seats, all bikes should be made so fish can use them.
>>
>>60032534
today  : Anime -> Programming  -> Type 
today anime prog = if (tired prog) then Masturbate Anime () -> Sleep Nat else Anime -> Programming -> Sleep Nat
>>
>>60032647

Make a list of lists of songs with matching names, and rename each of them based on their index.
>>
>>60032747
kys parasite
>>
>>60032647
Use a dict for your counter and map it name => count.
>>
>>60032770
How can anybody be this delusional?
>>
Why aren't yall in church?
>>
>>60032812
Christianity is unethical.
>>
>>60032823
Everyone with a brain begs to differ.
>>
Math grad here just stopping by the zoo to feel better about myself. Whew, stinky in here!
>>
>>60032843

What's it like making 300k right out of college?
>>
trying to make an online checkers game in c++ using sockets.

so would I have to make 2 threads for the client? one to maintain the connection and another to run the game?
>>
File: 1492865665232.png (18KB, 744x247px) Image search: [Google]
1492865665232.png
18KB, 744x247px
>>60032770
>>
>>60032828
Everyone with a brain knows that Abrahamic religions are cancer.
>>
>>60032867
Sounds exactly like the problems communism is facing. You'd think they would have found some attempt at solutions.
>>
>>60032851
That's funny, haven't thought about money in years. Finance feels good bru, keep making me those libraries or whatever you do
>>
>>60032747
What does
Sleep Nat
do?
>>
>>60032887
I assume Nat means natural numbers, so sleep for >(=?) 0 of some unit of time.
>>
>>60032908
I understand, but where is it defined?
>>
>>60032887
It's built into my compiler.
>>
>>60032940
What's the value of Nat.
>>
>>60032940
meant for >>60032920
>>
>>60032823
Other religions also have churches.

>>60032882
Uneducated American screams communism at everything.

I'm not religious or communist.
>>
>>60032951
data Nat = Z | S Nat
>>
>>60032953
Uneducated E*ropean screams "American" at everything.

I'm not American.
>>
I've been trying to come up with a function which takes in 2 longs (left and right half of a 128-bit value), concatenates them, performs a left circular shift of k bits, and divides them back to longs and returns them. I m so fucking lost it looks impossible to me FUUUCK. Why don't the JAVA guys push a fucking 128-bit integer data structure?
>>
>>60033001
Uneducated American pretending not be American thinks the world id just US and Europe.

(If you are really not American there is no excuse for being so uneducated)
>>
>>60032579
Hello C++ programmer. Have you found a way to communicate across the millions of dialects you have?
>>
>>60033039
Que?
>>
>>60033042
Hola programador C ++. ¿Ha encontrado una manera de comunicarse a través de los millones de dialectos que tiene?
Esto fue traducido usando google translate.
>>
>>60033025
Somebody as subhuman as you just has to be E*ropean, there is simply no other way. There is also the possibility of you being C*nadian, but I don't even want to consider that right now.
>uneducated
How can you possibly make any claims about being "educated" when you think I'm somehow American even though it's pretty clear that I'm not.
>>
>>60033017
still better than working with timespec structs.
Image your problem but the lower value carries at 10^9
>>
Physical therapy/sports medicine student here. Lol you retards are pretty funny, you actually like this shit? Come hang with me we'll go to the strip club. Anyway who wants to help with my Java assignment
>>
>>60033051
¡jajajajaja!
>>
Question about a custom monad in Haskell. Say I have something like:
data Point a = Point {x::a, y::a, z::a} | None
instance Monad Point where
(Point a b c) >>= f = f -- What the fuck goes here?


Why can't I actually get bind to work, i.e. \x y z -> Point (x + 5) y z ? I've looked online, and things like bind2 kinda exist not really, but it's more curiosity at this point.
>>
>>60033058
t. ameritard
>>
>>60033058
are you upset?
you sound upset
>>
>>60032882
This this a bot? This is verbatim what I replied to someone who explained that GPL would be great if only everyone used it.
>>
What does [-V] mean in a regex? I thought it would mean any capital letter up to V but that doesn't work.
>>
>>60033128
in square bracket
it means anything that ain't '-' or 'V'
>>
File: rapic.png (4KB, 640x400px) Image search: [Google]
rapic.png
4KB, 640x400px
How many interrupts is enough interrupts?
>>
>>60033128
You want [A-V] then.
>>
>>60033096
Is that so?
>>60033110
I don't know...
>>60033123
I was quoting you since I really like how that sounds for some reason.
>>
>tfw you programming chair starts to smell like shit
>tfw that smell interferes with your work
>>
>>60033187
That's because you're a filthy smelly man.
If you were a girl you wouldn't have these issues.
>>
File: PICxie.png (52KB, 375x474px) Image search: [Google]
PICxie.png
52KB, 375x474px
>>60033157
>>
>>60033017
hey, what if you do it like this:
you have l1 = 1001 and l2 = 0100.
you know the length, 4 bits:
temp1 = l1 >> 3 (shit right logical), so you saved the most significant bit of l1, temp1 = 0001
temp2 = l2 >> 3 = 0000

now you do l1 = l1 << 1 = 0010, l2 = l2 << 1 = 1000
then l1 = l1 | temp2 = 0010
and l2 = l2 | temp1 = 1001

now you have 0010 1001 which is 1001 0100 shifted left circularly.

for k bits, if k <= length(l), you could simply do
temp = l >> length(l) - k

and
l = l << k

if k > length(l) you could probably divide above in parts like k_1 = k - length(l), k_2 = k_1 - length(l) so that you don't lose any bits... or simply use a loop and never check if k > length(l).
>>
>>60033210
Sometimes I wish I was a computer science qt pie
>>
Is there any decent debugging software for ncurses?
The "let gdb output to another terminal" works okay but setup is tedious and it somehow fucks up the COLS and LINES values making it impossible to debug issues arising from terminal size ...
>>
noob here

why doesnt the java collections API doesnt become a part of the language?
>>
How do we get completely rid of headers in C++?
>>
hello /g/, programming babby here.

I'm second year at uni, and I've taken a few CS classes that were required for my major (Im mechanical engineering), but I want to learn more coding. Where can I do other than code academy? The class I took basically covered everything they have in python.
>>
File: 2017-04-23-165349_574x253_scrot.png (26KB, 574x253px) Image search: [Google]
2017-04-23-165349_574x253_scrot.png
26KB, 574x253px
So I've thought up the features for my Node.JS OS:
>exokernel that only prevents race conditions and illegal access
>javascript drivers and access to devices based on privilege
>POSIX compliant base system
>framebuffer allowing GUI windows in the console and mouse
>code editor with autocompletion for JS and Node / system functions
and my favorite
>adding the output of the last command in your current command line
>>
>>60033316
Admit defeat and break C backwards compatibility completely.
The committee will never do that. And it's not like the headers are that big an issue in the grand scheme of C++ issues really. They back a lot of design choices, that's their issue. But you'd have to change the language drastically to see the gains.
>>
>>60033330
>>POSIX compliant base system
>>framebuffer allowing GUI windows in the console and mouse
>>code editor with autocompletion for JS and Node / system functions
>>adding the output of the last command in your current command line
This is all userspace shit. That has nothing to do with an OS.
>>
Has anyone ever made anything useful (other than emacs) with lisp?
I mean even haskell has xmonad
>>
>>60033083
The primary difference between an applicative and a monad is the operation join (achieved via bind)

join :: m (m a) -> m a
What would this do for your Point class?

i.e.
{(xx,xy,xz), (yx,yy,yz), (zx,zy,zz)} -> {?x, ?y, ?z}
>>
>>60033330
>prevents race conditions
How are you planning to do this? I don't see how you can decide the order for every program just like that.
>>
>be a functional programmer
>I/O slaps my gf's ass
>cry
>>
>>60033390
It's very clear that he knows absolutely nothing about OS design.
I doubt he hasn't thought of anything just the most vapid shit.
>>
>>60033083
>>60033388
In fact what you want doesn't seem to relate to monads at all.

You should look into lenses.
A simpler example would be this though
Write a function, overX, that takes a function (a -> a) and applies it to the x parameter, keeping the others identical
>>
>>60033363
>This is all userspace shit. That has nothing to do with an OS.
an OS is a complete thing, like FreeBSD
>>60033390
I meant to say applications attempting to write to the same address and places they're not authorized in (for ex a guest user resetting a PCI device)
>>
File: 134651345.png (317KB, 566x302px) Image search: [Google]
134651345.png
317KB, 566x302px
>>60032148
>>60032172
>>60032192
>>60032196
>>60032211
>>60032239
>>60032248
>>
>>60033399
>It's very clear that he knows absolutely nothing about OS design.
>I doubt he hasn't thought of anything just the most vapid shit.
Calm down bro, we get it you're the most 1337 h4x0r here, nobody is challenging your 4chan alpha male status.
>>
>>60033385
The base of emacs is written in C.
Programs made in lisp
Maxima
Allegro graph
Some parts of Mirai
...
>>
Who owns C?
>>
>>60033409
>I meant to say
Virtual memory systems tend to handle this just fine. You should look into it.
>>
>>60033428
An OS isn't something you just write. It's an extremely complex beast, requiring a lot of specialised, low-level knowledge. It's very clear that you are not up to the task.

>>60033449
ISO.
>>
>>60032063
What exactly is so hard about C? I'm reading K&R and so far it seems pretty simple, refreshingly so. I like it much more than I liked learning Python.
>>
>>60033462
C is not a particularly hard language. It just doesn't protect you from your own stupidity, which idiots seem to think is "hard".
>>
>>60033462

SHUT UP
>>
>>60032953
>>60033025

Only people who are communists defend communism.
>>
so I have
data Yoyo =
Yo String String
deriving (Show, Eq)

getit :: String -> IO (Maybe [Yoyo])

how do I "remove the IO" from the returned value of getit? So that I am left with [Yoyo]
>>
>>60033453
ARM64 has special instructions for exclusive access, the kernel will just offer a way for applications to use the memory using those
>>60033453
> It's very clear that you are not up to the task.
Am I not up to the task or are you just hoping I'm not in order to not feel bad about getting nowhere in your life?
>>
>>60033493
main :: IO ()
main = do
x <- getit
return ()

you can't unwrap it in a non-IO function
>>
>>60033443
>Some parts of Mirai
Source?
>>
>>60033462
Once you start writing bigger program you basically have to implement your own data structure / allocator libraries because there is no good one, you could use Glib which but it's huge.
>>
>>60033511
https://en.wikipedia.org/wiki/Mirai_(software)
>>
>>60033513
That explains it. I haven't moved on to any larger projects yet
>>
>>60033316
https://clang.llvm.org/docs/Modules.html
>>
>>60032095
it's leon trotskij
>>
>>60033462
Some argue that C is hard because there's edge cases. Usually undefined behavior to consider. Argument goes that you can't write anything big before you know all the edge cases because you will run into them and things will be ruined. I don't agree, it's work for any programmer to deal with bugs and as long as you're diligent about fixing things it doesn't end up being all that difficult.

I think it's mostly 'hard' because of the problems you deal with in C. When you work in any low level work-enabling language you do it because you care about that stuff. So it's a domain that is kinda difficult. And usually you have these extra concerns on top of your ordinary concerns. Like maybe you're doing some complex simulations but you also have to make it perform well. That's more difficult than doing those complex simulations without caring about performance. So people confuse the problems they have to solve in the language with the language being hard.
>>60033513
Allocators only really get difficult when you're dealing with completely generic workloads (like malloc would). For almost every other case you have a few general ones you can lean on and the specialized ones are just about you expressing what you wanted well.
I'm sure you could find some situation where an allocator is hard but it's not a generally difficult thing in C.
>>
>>60033505
>responding to bait
>>
>>60033567
>ignoring bait
>>
>>60033505
thanks, so then how would I filter for the first string of Yoyo's then print?
main:: IO ()
main = do
x <- getit
maybe err kek
where
err = putStrLn "error"
kek = print $ filter ?
>>
do you think McCarthy had autism
>>
>>60033402
I've really just been messing around with them to get a handle on the concept. I've read a bit, and watched a video someone here posted a yesterday, and I kinda grok it in a basic sense. From my understanding, monoids = basically functions closed under composition, i.e. two functions taking/return Integers, when composed in anyway, will always return an integer. Monads are like monoids, except for a join function, that can reduce composed functions into a single one (through use of bind). Why then am I limited to passing only a single fielded (?) types down my joined functions? Sorry if that all sounds stupid.
>>
>>60033580
>>60033567
>>
>>60033227
Hmmm looks interesting, trying to implement this right now
>>
>>60033605
>autism
It's just an arbitrary judgement on personality.
I'm sure many scientists fit on the autism spectrum because of the general trend of being very single minded.
>>
>>60033607
What would happen if you passed a function (a -> M b)?
Your Point class couldn't have a B and two As
If you can't pass an (a -> M b), then it definitely not a monad

Just applying a function to a particular part of a structure isn't really monadic (maybe comonadic), this is the sort of thing you use lenses for.

For a monad, it has to be able to change the type variable, which in your case means x y and z, not just one of them
>>
>>60033602
maybe err flt x

flt = print . filter (predicate)
>>
>>60033486
>people
>who are communists
What did he mean by this?
>>
>>60033642
thanks
>>
File: 1492902779419.png (118KB, 694x732px) Image search: [Google]
1492902779419.png
118KB, 694x732px
Any Java friends want help a cretin?

I've have an ArrayList<CarSpace>
When I want to display all the fields I write :
carSpaces.get(i);


Integer "i" being the index, This calls my 'toString()' method in my CarSpace class and displays all the fields for that index in the ArrayList.
What I want is to just get the value for just one of the fields ( its a char ). I then want to sort the ArrayList by this char. [a-z].

This is the pseudo code to try and get my request across. Also any have tips/source on how to sort ArrayLists with the comparable as I've yet to understand it completely.

       carSpaces.getZone(carSpaces.get(i)); 


Also any have tips/source on how to sort ArrayLists with the comparable as I've yet to understand it completely. Thanks in advance.

For humor a student in /sci/ posted this yesterday which is the code for his group project.
http://ideone.com/c697Lt
>>
>>60033697
Post the code what you have right now.
>>
>>60033648
https://youtu.be/U01xasUtlvw?t=136
>>
>>60033637
I mean that kind makes sense. But say my Point can be 3 of anything, i.e. data Point a b c = Point a b c. In my case, couldn't I havea function \a b c -> M x y z, since the point itself is the 'monadic container'?
>>
>>60033776
No, you have 1 type parameter, and the functor/applicative/monad classes only deal with the last type parameter anyway.

What you want is just to have the type parameter specialised to a tuple
But then you aren't using your point class, and you'd be using the identity monad anyway, defeating the entire purpose
>>
>>60032103
Thank you a bunch
>>
>>60033766
For which?
I have none for getting a single field out of an ArrayList<Object>.

As for the Compareable not much :
public int compareTo(CarSpace other)
{
int value;

if(this.zone < other.getZone())
{
value = -1;
}
else if(this.zone > other.getZone())
{
value = 1;
}
else
{
value = 0;
}

return value;
}



'Zone' being a char from [a-z].
>>
>>60033860
What about
Collections.sort(carSpaces, (lhs, rhs) -> {
if (lhs.getZone() < rhs.getZone() {
return -1;
} else if (lhs.getZone() > rhs.getZone() {
return 1;
}
return 0;
}
>>
File: 1420065292964.jpg (44KB, 581x266px) Image search: [Google]
1420065292964.jpg
44KB, 581x266px
>>60033697
>http://ideone.com/c697Lt
Nice "win checking" approach :^)
>>
>>60033835
Hmm, I guess this:
 functor/applicative/monad classes only deal with the last type parameter anyway.

was kinda the part I was caught up on so far, Thanks!
>>
>>60032509
>He shows off a couple of bits here:
Thanks. Hadn't found that one. Looks good.
>>
File: Chapter13.png (141KB, 1049x724px) Image search: [Google]
Chapter13.png
141KB, 1049x724px
>>60033849
Neat, the idris package for Atom has a key command for type checking of terms, the whole code as well as a REPL box
>>
>>60034048
3 types have been added to your account
>>
>>60033914
Thanks, I don't know how to use the '->' operator or lhs,rhs. So I don't really understand how to pass values to those if I even have to.
>>
>>60034070
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Lambda-QuickStart/index.html
>>
>>60032103
How does Idris compare to Coq? The theorem proving capabilities seem limited, but appear to be based on the calculus of constructions as well.
>>
>>60034096
Interested in this too.
>>
>>60034087
Thanks.
>>
I giggle everytime I read Coq
>>
>>60034137
https://www.youtube.com/watch?v=FiJd_d8I-iE
>>
>>60032126
good language until Ada 95
>>
>>60033325
pls respond ;_;
>>
>>60033325
>>60034159
projecteuler.net has a selection of tasks that can be very beneficial, they are heavily math based though and often require some form of preparations
>>
>>60034185
thanks
>>
>>60034159
codeforces
codewars
leetcode
hackerrank
topcoder
interviewbit
sicp exercises

pick ur poison and solve a few every single day like a madman
>>
>>60033325
Figure out a project you want to do and figure out how to do it.
>>
File: cmd.png (152KB, 706x624px) Image search: [Google]
cmd.png
152KB, 706x624px
>>60034096
The outlook is completely different.
Here the creator talks about the difference to Agda.

http://stackoverflow.com/questions/9472488/differences-between-agd

I'm not sure if the jury is out on the language yet. It's more like haskell but I think programming will be quite different than in Haskell. E.g. if you read the Chapter 13 example that I posted above (Vending machine), there will be much more happening in the type system (naturally), than it does in Haskell.
E.g. you have the machine states (in the sense of a finite state machine) effectively encoded on types depending on what's in it (money, food to get out) and what you can do (e.g. get money out of it, put coins in,...) is naturally dependent on the state of it and thus on the current value of the dependent type, resulting in the whole operator to be type safe and the do-comands you implement so rigidly typed that the compiler will not create code unless it really works out.
The type system in Haskell seems rudimentary in comparison, here you actually do much or most of the coding by type designing.

Perks are that it's hard to learna and will stand and fall with the size of the community, as it develops.
a-and-idris
Here many questions come together, the 1.5 "best tool for" thread gives an outlook to what people think it can do and what not.

https://groups.google.com/forum/#!forum/idris-lang
>>
>>60034137
I do giggle when my instructor proclaimed: "Now, I will show you Coq in full glory".
Thank the crazy frenchman, mister Coquand. Also, it was named CoC (after the calculus of constructions) initially.
>>
>>60034244
>Perks are that it's hard to learn
Is it easier if you're already familiar with (inductive) type theory and programming in Coq?
>>
File: 1492902651310.png (141KB, 800x600px) Image search: [Google]
1492902651310.png
141KB, 800x600px
>>60033914
Another thing, Where to I place the compareTo() method?
I have 3 classes:

+ The CarSpace class which is the just the object for the ArrayList; this class only has primitive data types.
+ The CarPark class where the ArrayList<CarSpace> is stored and where my methods for getting data from the ArrayList are.
+ Finally I have a MainApp where my main() is; this has a few methods.

I've only ever used a compareTo() with two classes e.g: Employee and MainApp.

Employee :
public class Employee implements Comparable<Employee>
{

@Override
public int compareTo(Employee other)
{


if(this.salary < other.getSalary())
{
return -1;
}
else if(this.salary > other.getSalary())
{
return 1;
}
else
{
return 0;
}

}
}


MainApp :
Collections.sort(employees);


Being honest I don't even understand how Collections.sort works. I understand what the integer being returned means but past that.
>>
tl;dr you write programs to run them, not just to compile (=see if a theorem holds). So I wouldn't compare them, the difference to other language is molstly that you have finite sets and the natural numbers as parameters on the type level
>>
My binary search tree keeps crashing. Why is this anons. :S

 

const int value = num;
BSTNode *new_Node = new BSTNode(value);
BSTNode *temp_root;
temp_root = root;


//No Nodes in Tree
if(root==NULL)
{
root = new_Node; //Root pointer points at the New Node
}



else
{

//Iterate until temp_root is NULL
while(temp_root!=NULL)
{

if(num < root->value) //When Node's # is less than Current Position in Tree
{

if(temp_root->left == NULL) //If there's no Child
{
temp_root->left = new_Node; //Make one
temp_root = NULL;
n_elem++;
}
else
{
temp_root = temp_root->left; //Otherwise place the pointer at that Position
}

}

else //Same but other way
{
if(temp_root->right == NULL)
{
temp_root->right = new_Node;
temp_root = NULL;
n_elem++;
}
else
{
temp_root = temp_root->right;
}
}


if(num == temp_root->value) //Increment Counter
{
temp_root->count = temp_root->count + 1; //Increment count
temp_root = NULL; //Get out of Loop
}

}

}


>>
>>60034265
Obviously.
>>
I'm gonna study the official java documentation to learn java

tell me why this is not a good idea
>>
>>60034244
That might be true for Haskell 98, but a lot has happened since then.

It's easy to say "Haskell is so rudimentary" while using a language based largely on advances that have been spearheaded by Haskell and light that's been shone on FP and type theory by Haskell's relative popularity.

You are using GADTs and what would in Haskell be called indexed monads.
Yes, Haskell doesn't have dependent types, and when they're added they won't be as natural as Idris.
>>
>>60034306
It's completely valid, as long as you suck Oracle's cock at the end.
>>
>>60034339
How does one suck a coq of a huge corp though
>>
>>60034350
By being their little bitch.
>>
>>60034271
Override the compareTo method in the class you want to sort. That would be CarSpace in your case.
>>
>>60034350
You send them a 'proof' containing a non-terminating tactic, of course!
>>
File: fugme.png (54KB, 929x536px) Image search: [Google]
fugme.png
54KB, 929x536px
How do I get normal results?
>>
>>60034381
Use Rust.
>>
File: academia.jpg (140KB, 1200x700px) Image search: [Google]
academia.jpg
140KB, 1200x700px
>>60034265
Well I'm pretty sure, yeah. I also come from the category theory side, I'm not a programmer, even if I write Python GUI's for experiments on quantum computers (>inb4 Python GUIs, >inb4 /g/ elitism). Btw.
https://www.youtube.com/channel/UCcrSMnEYhIPX_p127jI23qw
You may subscribe above. I'll do a video series on what I read in the book in June

>>60034316
Don't get me wrong, I like Haskell and the way programmers break apart mathematical structures that suit them

>>60034246
There was this thread on /sci/ years ago (and sadly the joke won't work as well when I just recite it here), where OP asked
>I have a philosophy student come over to help her with her logic exercises, how to impress here
and the first reply was
>Show her ya coq
>>
>>60034378
Okay, just to make it clear.
I want to sort the Object ArrayList which is in CarPark so I compareTo() in the Object class for that ArrayList, like the toString() ?

Thanks anyways Anon I'll do it now.
>>
File: defusal.png (277KB, 2780x860px) Image search: [Google]
defusal.png
277KB, 2780x860px
>>60034390
Well anyway, the point is you can do that sort of thing in Haskell, but not as well without dependent types.
>>
>>60032063
A tour of Go
https://tour.golang.org

90% of Python in 90 Minutes
https://www.slideshare.net/MattHarrison4/learn-90
>>
>>60034287
Use a debugger.
>>
>>60034417
Correct, just like you did with the toString() method.
>>
>>60034381
Use printf
>>
>>60034381
They're normal, just using the scientific notation.
You can use std::fixed to suppress those.

http://en.cppreference.com/w/cpp/io/manip/fixed
>>
>>60034433
I know about it from SO threads and I heard the community has a (maybe too) big influence on where ghc is going and how things are rewritten. Sadly, the work I do irl are either Python/Matlab scripting and C++ because of the libraries that will never ever overcome and so I push functional language to my private live
>>
>>60033325
JUST DO IT.

Do you like MtG? Make a command line version of a game similar to MtG. If you're smart you'll implement it keeping a MVC model (google it) in mind. Then replace the command line interface with a windowed interface with card art, etc. Use a protocol like MQTT to enable networking.

Don't like MtG? Think of some game you do like that can be represented on command line and do the same.

Don't want to do a command line game? Download Unity and learn that.

Create a dating website for some niche and make it promote yourself over other dudes. Django will help with this.

Get an Arduino and program it to do cool things.

If you need inspiration, check out https://html5zombo.com/
>>
>>60034471
What if I don't like anything
>>
Currently a student. Have aspirations in audio signal processing and chemical/materials simulation. Where tf do I start with programming?
>>
>>60034503
C++, so you have a perspective on an actual language when you're eventually forced to only use MatLab
>>
>>60034499
Then get fucked.
>>
>>60034503
C++ and if you have a nvidia video card with cuda cores you can run your c++ code directly on it.
>>
>>60032509
>https://www.youtube.com/watch?v=gWv_vUgbmug
shit.
Now I'm hyped for jai, too.
>>
clojure seems like such a mess compared to other lisps, especially clojurescript
>>
>>60034433
>Still reposting this shit
How many cum-stained copies of this would someone find scattered around your room
>>
File: moot.jpg (85KB, 1024x512px) Image search: [Google]
moot.jpg
85KB, 1024x512px
>>60034986
Who are you quoting?
>>
>>60032063
Thank you for using an anime pic
>>
>>60034935
I like kawa better if you need to compile to jvm.
>>
>>60035109
>scheme that runs on JVM
fucking neat, shame it doesn't seem to have support
>>
std::remove_if(resources.begin(), resources.end(), &std::shared_ptr<Resource>::unique);


WHY CAN I NOT WRITE IT LIKE THIS

WHY IS C++ SUCH A SHIT LANGUAGE

REEEEEEEEEEEEEEEEEEEEEEE
>>
>>60033227
Anon works like a charm, thank you and god bless you.
>>
File: defuse.png (140KB, 1920x1057px) Image search: [Google]
defuse.png
140KB, 1920x1057px
>>60034433
Just did the same in C++ for fun.
>>
Am I autistic?
>>
>>60035299
I know right, instead C++ forces you to write this which is a whole one character longer...

std::remove_if(begin(resources), end(resources), [](auto res) { return res.unique(); });
>>
>>60035350
nice
Haskell doesn't have type level functions for certain reasons
>>
>>60035299
>sepples in charge of making sense
>>
>>60032083
I am amazed no one took the bait.

Has /g/ realized the truth?
>>
>>60035399
I know that I can work around the dirtiness of C++ with lambdas, which they probably introduced exactly because of the nonsense which is <algorithm><vector> etc. I'm just being mad because the stl is so badly designed.
>>
>>60035408
The Haskell one is still nicer though because the one I made can only tell you at compile time whether a sequence is valid or not, it cannot pinpoint the specific color in the sequence that fails the rules, I'm sure it's doable but I'm not good enough with templates to make it work.
>>
File: 131.540.jpg (24KB, 626x352px) Image search: [Google]
131.540.jpg
24KB, 626x352px
Anyone going to WAD this year?
Since it's in my hometown this year and my company is paying for the tickets, I sure am.

Gonna try the VR games and listen to motherfucking John Romero & Peter Sunde for sure.

Schedule https://www.wearedevelopers.org/schedule/
>>
>>60035479
Here's the equivalent C++:

struct Red;
struct Green;
...
struct Red {
Green green(); // valid
}

Green green;
Red red;


red.green(); // valid
red.red(); // invalid, method does not exist, compiler will say "Red does not have method red"
>>
>>60035326
great! I'm glad I could help.
>>
>>60035479
>it cannot pinpoint the specific color in the sequence that fails the rules
A static_assert in ValidStateChange() in each branch should work, I think. Also, your Sequence template can be made shorter with fold expressions.
>>
File: C9igqo0XcAARLmU.jpg (13KB, 378x343px) Image search: [Google]
C9igqo0XcAARLmU.jpg
13KB, 378x343px
gimme a non-meme project to make my github look kewl
>>
>>60035680
the fuck is this gay shit
>>
>>60035357
Only if your github page looks like this

https://github.com/syohex
>>
File: work.png (9KB, 712x189px) Image search: [Google]
work.png
9KB, 712x189px
>>60035742
jesus christ
>>
this is sort of relevant so I will post it here.

how do I get my github profile to be the first result in google search? I search "github [myprofilename]" and it is not even on the google search result. it will only do it when I write "github/[myprofilename]"

what appears when I type the first option is some other guys profile with a similar name.
>>
what is you guys' favorite programming-related freenode channel?

all the most popular ones just seem to be a couple people talking and 1000 idlers
>>
File: not my wm theme.png (3KB, 640x400px) Image search: [Google]
not my wm theme.png
3KB, 640x400px
I'm trying to come up with a default palette for RGA.
Anyone got ideas for colors?
>>
File: 1469407495293.jpg (12KB, 238x192px) Image search: [Google]
1469407495293.jpg
12KB, 238x192px
Programming newb here. Java question...

How would I do something like this?

Say I have:

List<String> list = new ArrayList<String>();

list.add("John");
list.add("Sally");
list.add("Bob");

and I want to create a hashmap that loops through list and add all the strings in list followed by the number 1.

Second part.

How would I look through the hashmap and look for "Bob" and if "Bob" appears add a plus 1 to his value?

This is a made up problem on my part so it doesn't really make sene other than I'm trying to understand how to use hashmaps in java.

I think I got the first part need help with the second


public class Practice {

public static void main(String[] args) {
List<String> list = new ArrayList<String>();
list.add("John");
list.add("Sally");
list.add("Bob");

Map<String, Integer> map = new HashMap<String, Integer>();

for(int i=0; i<list.size(); i++){
if(!map.containsKey(list.get(i))){
map.put(list.get(i), 1);
}
}
}

}


>>
>>60035961
Dumb frogposter
>>
>>60035961
Why don't you add it directly to the Map?
>>
>>60035982
I'm basically am trying to make up a problem when you say 'if hasmap contains string key already add one to the string key's value'

how do you do that?
>>
>>60036000
>>60035982


Because this doesn't work


Map<String, Integer> map = new HashMap<String, Integer>();

for(int i=0; i<list.size(); i++){
if(!map.containsKey(list.get(i))){
map.put(list.get(i), 1);
} else {
map.put(list.get(i))+=1;
}
}
}

>>
What is the cringiest language?
>>
>>60036042
French
>>
>>60036035
idiot
>>
>>60032428
>>60032509
>>60034911
>no references
>no RAII
>no templates
Excellent. Can we get rid of polymorphism too?
>>
>>60036035
for (String s : list) {
if (map.containsKey(s)) {
Integer i = map.get(s);
i += 1;
map.put(s, i);
} else {
map.put(s, 1);
}
}
>>
>>60036100
https://www.youtube.com/watch?v=BwqeFrlSpuI
It's different.
>>
>>60036118
Dropped. I'm not interested if the compiler's going to generate code I didn't actually write.
>>
>>60036102
This makes sense

Thank you
>>
>>60036138
>I'm not interested if the compiler's going to generate code I didn't actually write.

i wrote a compiler for you, in haskell:


main = interact id
>>
>>60035742
>>60035767
Well,
1. He get's paid for it.
2. Everyone can spam commits. Doesn't mean someone did alot of code or even good code.
>>
>>60036138
Fair enough. You could have watched the video though. It's a shorthand for a basic metaprogramming procedure.

As it's very often you just want to replace types.
>>
>>60036156
What language does it accept as input?
>>
>>60036243
All of them.
>>
>>60032164
>ML was invented in 1973
>Smalltalk was invented in 1972
>Lisp was invented in 1958
>C was great in 1972
>>
>>60036281
Lambda calculus, 1930s
>>
File: 1486087811340.jpg (31KB, 438x428px) Image search: [Google]
1486087811340.jpg
31KB, 438x428px
>>60036255
Is there a way to limit the set of languages it accepts? I need a Haskell compiler.
>>
>>60036346
No. It also performs IO, so it's limited in that sense too.
>>
>Return value
>Type: SHORT
>The return value specifies the status of the specified virtual key, as follows:
>If the high-order bit is 1, the key is down; otherwise, it is up.
> If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled.

I'm a little confused what they mean by
>the high-order bit
>the low-order bit

A short has 16 bits, doesn't it? Not just 2.
>>
>>60036281
C was the only one of these languages that could actually be implemented in 1972. The others were purely theoretical for many years.
>>
>>60036431
Link?
>>
>>60036445
https://msdn.microsoft.com/en-us/library/windows/desktop/ms646301(v=vs.85).aspx
>>
>>60036431
In which case it's the 8/8 rather than 1/1.
>>
>>60036481
Thanks. Please include it right away next time, so people can verify the validity of your posts for themselves.
>>
>>60036440
wrong
>>
With forward declerations in C++, do I need to account for inheritance?

struct Entity;
struct Player: public Entity;


vs:
struct Entity;
struct Player;
>>
>>60036513
Wouldn't it have avoided confusion if they had just said 'bits' in plural then?

And also, from my debugger it looks like they meant 12/4.
>>
>>60036614
no
also
>structs with inheritance
>>
File: C.png (5KB, 550x380px) Image search: [Google]
C.png
5KB, 550x380px
I have a question about data logging in the context of high-performance simulations. We gather data at 100Hz in sim time which gets written to file and analyzed by our GNC team.

Is it faster/more efficient to write the data to disk continuously as the sim runs (i.e. 100 writes per sim-second) or store the data in memory and dump it to disk once the sim finishes?

I'm leaning toward the latter being faster as I understand disk writes are an expensive operation, but I don't know enough about the details of I/O to reason about it intelligently. I'd like to hear pros and cons to each approach or some sources I can read myself.
>>
>>60036614
No, pretty sure you don't. Although that's easy enough to test. You should do that.
>>
>>60036657
depends on the operating system and how you implement the file writing

the OS might not actually write the data to the disc until you fully close the file handle, which means you're really doing the second approach when you think you're doing the first one
>>
>>60036632
>>structs with inheritance
What about it?
>>
>>60036694
I'm fairly certain it's the first operation. I can kill the sim halfway and view view half a run of data. We run on Red Hat 6.
>>
>>60036710
Classes support inheritance because they're reference types. Structs are value types.
>>
>>60036737
>I can kill the sim halfway and view view half a run of data
when you kill the process the file handle gets closed
>>
>>60036741
Structs in C++ are classes with the default visibility set to public rather than private.
>>
File: bsg.jpg (66KB, 400x400px) Image search: [Google]
bsg.jpg
66KB, 400x400px
>>60036710
>What about it?
>>
>>60036657
>I'm leaning toward the latter being faster as I understand disk writes are an expensive operation, but I don't know enough about the details of I/O to reason about it intelligently. I'd like to hear pros and cons to each approach or some sources I can read myself.
It makes little difference, as the operating system won't actually write the data to an actual disk until it can write a big chunk. If you write continuously, the operating system will buffer up the data for you until it has a large chunk to actually write or memory is running out.

If you need to write more than, oh, ten thousand distinct writes per real-time second, I imagine buffering all the data inside your application for a while will be slightly faster if you do it right, because it avoids the system call overhead. Anything less than that, you are very unlikely to notice a difference.
>>
>>60036657
Why not just make a copy of the sim every time you need to dump the data and enqueue it in another thread which dumps the data onto the disk? This way, even if the I/O is slow, it's getting dumped in a thread-safe manner to the disk without blocking the simulation.
>>
>>60036657
The reason you would write to disk is that you can't accept long interruptions so you have to write out to disk regularly.
If you can always fit all of it in memory just do that. It's the fastest.
With most OSes you have page files too. It's a simple way of avoiding a long pause, not the most efficient but bare-able.

At 100hz of simple data gathering it's not an issue.
>>
File: FORTRANwhite.gif (33KB, 622x122px) Image search: [Google]
FORTRANwhite.gif
33KB, 622x122px
>>60036751
True. I can also watch the file grow as the sim runs.

>>60036773
Are there any good tools for profiling I/O? The final output file is on the order of 1GB, but I don't know the details of how it actually written. I've been using valgrind/callgrind to identify troublesome areas, but it doesn't capture I/O data.

Really we're just looking for low hanging fruit to speed things up. This sim is disgustingly slow compared to its legacy predecessor and other, more complex sims written in the same framework.


>>60036780
A separate logging thread of some sort is one of the approaches I would explore.
>>
Following this guide to build a Kernel module

http://www.tldp.org/LDP/lkmpg/2.6/html/x181.html

and got this after using insmod

insmod: ERROR: could not insert module hello-1.ko: Operation not permitted

What do? added my Kernel version in the makefile.
>>
>>60037044
uh

try running it as root?
>>
>>60037033
>True. I can also watch the file grow as the sim runs.
then buffering it yourself will help at least a little
but if it's
>disgustingly slow compared to its legacy predecessor
then this wont help nearly enough
you've probably got at least one poor choice of algorithm slowing it down
check all the places you sort and search first, as that tends to be the easiest to rule out
>>
>>60037033
>True. I can also watch the file grow as the sim runs.
That's not an indication of anything. As you write to the file, the visible file on the filesystem will grow, even when it hasn't actually hit the disk yet. The operating system will just store it to memory in the meantime, and actually commit it to disk when convenient.

Under no circumstances should the writing to disk anything slow anything down, unless you call sync() to explicitly wait for the data to hit the disk.

Doing the logging in a separate thread might still be wise though.
>>
>>60037061
it worked. thanks.
>>
>>60037084
>the visible file on the filesystem will grow, even when it hasn't actually hit the disk yet
not on Windows; it will say 0 bytes until the handle is closed
although I suppose what you're saying might be true for red hat
>>
>>60037123
>>60037123
next episode
>>
>>60033525
>https://en.wikipedia.org/wiki/Mirai_(software)
>tfw I thought you were talking about the botnet
>>
>>60035486
that's cool
Thread posts: 320
Thread images: 31


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