What are you working on senpai?
Old thread: >>52158558
first for haskell
YEAR OF THE LISP
YEAR OF THE LISP
YEAR OF THE LISP
How do I find the min and max of ten numbers?
second for ocaml
OCAML BEST LANGUAGE
>>52161828
LOOPS MOTHERFUCKER
HAVE YOU HEARD OF THEM?
>>52161828
sort
first element is min, last is max
Why aren't functional languages faster than C? Surely someone should be able to write a compiled functional language that leverages the vasty more explicit code to optimize better?
>>52161857
Go ahead.
>>52161857
they are faster
happy new year's people.
>>52161828int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
for(int i : numbers) {
if(i < min) {
min = i;
}
if(i > max) {
max = i;
}
}
>>52161872
Don't meme me. Every benchmark shows C/C++ leading the pack. Always.
>>52161872
no they aren't you delusional mutilated fucktard faggot
>>52161884
>>52161892
show proof
Threadly reminder that switches and if statements are deprecated
>>52161828
Use sleepsort(). The value that is returned first is the minimum, and the value that is returned last (you have to count the number of times the variable was altered using semaphores) is the greatest.
>>52161901
http://benchmarksgame.alioth.debian.org/u64q/which-programs-are-fastest.html
>>52161846
That's gotta be just to troll people. Or maybe a gag-question on a quiz.
No one is that stupid. I'm telling myself this. I want to believe. I want to believe.
>>52161771
/d[pc]t/ looks better senpai.
Daily Programing/Coding Thread.
We can even take it further:
/d[dcsa]t/
Daily Programming/Coding/Scripting/Anime Thread.
Whats the point of loops when tail recursion exists?
>>52161946
loops are faster and more readable in 99% of use cases
>>52161946
kill yourself retard
>>52161946
What's the point of tail recursion when you can just foldr?
>>52161946
not all languages have tail call optimization
>>52161946
Tail recursion compiles to loops
>>52161924
NO
if you go there there next year it will be
daily Programming/Coding/Scripting/anime-deleted/FULL_ON_GAY/TRAPS/SJW/JEWS
>>52161906
I love sleep sort
>>52161874
It's only 5:22PM in the earliest timezone of the United States (the only country that matters). It is not yet the new year.
>>52161901
http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=ocaml&lang2=gcc
http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=ghc&lang2=gcc
http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=fsharp&lang2=gcc
>>52161946
What's the point of loops when you can just copy past your code that is way more efficient than loops?
>>52161971
Or latest, rather, because I'm a maroon.
>>52161981
>fucking up your instruction cache
>>52161966
New drama for the new year.
>>52161965
Do you mean language standard may not require the implementation to have tco or that some languages have no implementation that provides tco?
It's not current-year < 1980 anymore and if your compiler does not support tco you should not be using it.
>>52161981
>What's the point of loops when you can just copy past your code that is way more efficient than loops?
Obviously trolling, but you do know that's literally what optimizing compilers do sometimes? It looks at the situation, and if appropriate, unrolls the loop. You leave those decisions up to the compiler, and your life is good.
>>52162008
tco means compiling to loops
as in the compiler has to clean up your retarded shit
How are match expressions so fucking based?
Why doesn't C++14 have them? What the fuck Bjarne?
>>52162021
>as in the compiler has to clean up your retarded shit
It already does it on so many places so saying support for tco is not needed is retarded.
>>52162036
You're on the wrong board buddy boy
>>52162049
You're right, I am. I've also been drinking today. In fact, I started drinking last night and didn't stop.
>>52162047
anon isn't saying tco isn't needed
>Tail recursion compiles to loops
it literally compiles to loops. recursive functions are fucking dumb as shit. you gain nothing except if you're a hipster reddit fag then it makes you feel smart because you're too retarded to realize how pointless recursive function calls are.
>>52161924
/d[dcsa]t/ - ((Programm|Cod|Script)ing|Anime) Thread
Edit: There's probably a better way to do this.
How do I write C in the most autistic way possible?
I already cast the return value of malloc and cast pointers before freeing them.
I also use register and inline unironically.
>>52162077
/dp+scat/
daily programming plus scripting, coding, and anime thread
>>52162074
tail calls simplify code and make it neater
>>52162084
sorry to break it to you but that's just straight up assburger
IGNORE TRANNY THREADS
REPORT TRANNY POSTERS
>>52162084
malloc error handling
QUICK, POST HOW TO FIND THE MIN AND MAX NUMBERS OF AN ARBITRARY INPUT, IN YOUR LANGUAGE OF CHOICE
>>52162114
no it doesn't.
>>52162123
She's not a tranny.
Shame on you, anon.
Don't equate me to that tranny poster.
>>52161828
Real or not that code gave me autism.
Andrei Alexandrescu Three Cool Things about D
https://www.youtube.com/watch?v=FdpaBHyQNco
>>52162148
i resent being called that, I only post hime from himegoto
>>52162134
from stdin?
>>52162084
>C89 only
>Check errno wherever possible
>-pedantic-errors
>Vim
>Use for every project and no exceptions
>Any libraries you use you must compile
>>52162152
I really like Andrei, he's a good speaker.
Walter Bright on the other hand...
>>52162148
what a poorly draw anime then
and the character looks kinda like this guy
>>52162084
>I already cast the return value of malloc and cast pointers before freeing them.
Wait, this isn't normal?
Holy shit what the fuck has Rob Pike been teaching me?
>>52162084
Handle literally every possible error (even fclose), with errno switches and everything.
>>52162166
kill yourself fag
>>52162212
Don't be rude, anon.
He might have shit taste, but there's no need for this.
Daily reminder
>>52162221
posting threads before the bump limit like he does is entirely unacceptable and has stirred up a lot of shitposting and image/thread wars
kill yourself
>>52161852
> sort
Um, no. I mean, that will work, but it's completely unnecessary.int result = userInput[0];
for (int i = 1; i < num_inputs; i++)
if (result < userInput[i])
result = userInput[i];
>>52161852
>>52162259
>implying he wrote that in C++
obviously it's optimised C
>>52162247
Absolutely uncalled for, we're all white here. We can have a civil discussion without insults.
>>52162195
>draw a girl
>call it a boy
people will defend this
>>52161857
They are. See OCaml and ATS.
>>52162197
casting return value of malloc is required if you want to maintain compatibility with c++
casting pointers before freeing is required if you're freeing const pointers.
>>52162303
It is literally a cross dresser.
I want to declare a character array and use a integer variable in it's name. So for instance [/code]char nameX [10][/code] where X is a variable i get from another part in the program, how would i do this ?
Language is C++.
>>52162331
Type the same name, do not attempt to use the same name, or bring out the macro glue.
>>52162331
Anon, what you've just said is one of the most insanely idiotic things I have ever heard. At no point in your rambling, incoherent response were you even close to anything that could be considered a rational thought. Everyone in this room is now dumber for having listened to it. I award you no points, and may God have mercy on your soul.
>>52162331
Write a precompiler in python to compile your almost C++ code to actual C++ code.
>>52162330
yeah sure, that's an easy excuse when all anime guys look like anime girls but taller and with shorter hair
is there even any reason for his character to be male, or was that thrown in as otaku fanservice?
>>52162356
>redditors still find this funny in 2016
holy shit
>>52162300
>we're all white here
Uhm, I'm Indian.
>>52162331
what the fuck
>>52162366
Atomize yourself, currynigger!
>>52162377
That makes a change, I thought someone would say "POO IN LOO".
>>52162409
DEDICATED
>>52162360
No, but Japanese men can be quite effeminate. In the actual show you clearly see that he's crossdressing.
>>52162331
Fun fact: the compiler gets rid of your precious variable names.
function countWords(str) {
return str.split(/\s{1,}./).length;
}
Find a flaw.
>>52162461
hundreds of times slower and memory hungry than C because it's running in your comfy padded javascript interpreter
>>52162456
And redundant whitespace and formatting, which is why you should do this >>52159457
>>52162474
Just imagine it was psuedocode.
Find a flaw.
>>52161857
Functional code _usually_ depends on a garbage collector. For instance, it's hard to statically reason about exactly which variables a referenced by a closure, and doing so often requires garbage collection to hold onto the references.
A solution could be to make everything immutable so that closures can just copy values instead of references, but then you get a performance hit due to no immutable state in other parts of the program.
Sure, some functional languages (Haskell, OCaml I think) will let you write very fast functions that just operate on integers (and you could write the same procedure trivially in C), but taking advantage of real functional features (lambdas, linked lists) often ends up slower than their less elegant imperative alternatives.
>>52162495
if we're doing psuedocode thenword_count(str)
find a flaw
>>52162197
Casting return values isn't autistic at all, it's good coding practice.
>>52162509
why?
>>52162506
your pseudo language is shit
>>52159457
10/10 bait
>>52162084
Isn't register deprecated and completely ignored?
>>52162519str.count.words()
:^)
>>52162506
>Completely missing the point of psuedocode
That doesn't explain the algorithm.
>>52162535
your psuedocode doesn't explain what split does
newfag here, simply trying to get the last 3 characters printed in upper case also how do you post code not like this shit
char x[] = "abcabc";
int i = 3;
while (x[i] != 0)
{
toupper(x[i]);
i++;
cout << x[i];
}
>>52162543
It splits it into an array, obviously.
>>52162437
but why does he wear the dress?
>>52162528
yes, register is ignored completely by newer versions of GCC
>>52162543
>>52162562
I don't think regex psuedocode is very reasonable
>>52162562
that's so dumbint count_wrds(char *str)
{
return do_thing(str);
}
>>52162565
Nobody cares who he is until he becomes her
>>52162579
The whole point of psuedocode not being a real language is that it leaves out unimportant implementation details in favor of details to clearly explain an algorithm so that you can implement it in your language of choice.
>>52162579
>>52162533
>>52162506
>>52162461
None of these are sensible "psuedocode"
>>52162562
rate my pseudocode guyswriteKernel;
Linus can step aside, the real programmer has arrived.
>>52162552function meme(str) {
return str.substr(str.length - 3, str.length).toUpperCase()
}
Stop being a hipster and learn JavaScript and you usetags.
>>52162605
> ;
it's shit
>>52162598
rate my sudoku
>>52162574
>he doesnt know regex
How do I learn javascript, guys?
>>52162616
[CODE] tags (lowercase)
>>52162084
I feel like casting your malloc's to use a reference when debugging segfaults is less autistic than keeping track in your head
>>52162618
python user please stop being harmful
>>52162645
First you buy a black dildo.
>>52162645
Let Brendan Eich fuck you in the ass.
>>52162662
are you insinuating that all javascript developers are homosexual?
>>52162644
>he doesn't just google the regex he needs
>>52162679
It's actually pretty easy senpai.
You shouldn't need to google the regex you need.
char x[] = "abcabc";
int i = 3;
while (x[i] != 0)
{
toupper(x[i]);
i++;
cout << x[i];
}
thanks man, not being a hipster just an idiot
>>52162461>countWords(" ")
>2
>countWords("")
>1
smdh
/sci/entist and Python pleb here.
I was wondering if anyone knew the most efficient way to do this.
Suppose I have an array (using numpy.array at the moment) of numbers like:array([[ 0. , 0. ],
[ 0.5 , 0.5 ],
[ 0.75 , 0.25 ],
...,
[ 0.90722656, 0.65917969],
[ 0.65722656, 0.40917969],
[ 0.15722656, 0.90917969]])
Each row corresponds to a coordinate/vector of arbitrarily large dimensions (n=2 in the example obviously).
I need to:
A) Find find the dot product (or the inner product/euclidean "distance") between each point), then
B) Rearrange new lists with the first entry being the coordinate in the original list and subsequent entries arranged from the "closest" to the "furthest" coordinate of all other rows in the original array.
I know for A) I can use numpy.inner to find the, but I don't know how to do this in an efficient array processing manner for all points.
Also there must be some bubble algorithm for B), but how do I keep track of the coordinate entry number in the original array (I need the original coordinates after the new lists have been sorted).
Would appreciate if someone could point me in the right direction. It needs to be as efficient as possible, we're talking about a lot of points here.
>>52162134
OK.
C++ WITH THREADING#include <atomic>
#include <sstream>
#include <string>
#include <vector>
#include <thread>
#define ms std::chrono::milliseconds
int main(void) {
std::vector<int> numbers{ 5, 7, 8, 9, 1, 4, 2, 3, 6, 10, 15 };
std::vector<std::thread> threads;
std::atomic<int> max, min;
std::atomic<bool> first = { false };
//modified sleepsort()
auto func = [&](int time) {
std::this_thread::sleep_for(ms(time));
if (!first.exchange(true)) {
min.store(time);
}
max.store(time);
};
//meaty part
for (auto i : numbers) {
threads.emplace_back(func, i);
}
for (auto& t : threads) {
t.join();
}
printf("Min: %d, Max %d", min.load(),max.load());
}
>>52162792
What's your favourite anime, anon?
not gonna lie lads, python is pretty tight, tighter than my cousin's vag
>>52162792
/dpt/ is not really the place to go asking how to use numpy. This thread is about general programming shit. Time to learn to use IRC.
/cuck(old)?/ig
Gotta admit, regex is pretty fun ngl.
>>52162823
I haven't watched anime in ages, don't have facourits and don't watch a lot to begin with, last one I was able to actually finish was NGE. Cowboy Bepop was the last one I watched, but it got too boring after the weird people joined the crew.
>>52162938
I use IRC, which channel do you recommend? One of Rizon's?
I'd use stackexchange, but my adviser wouldn't like seeing elements of my project on the indexed web.
>>52163003
try freenode, #python maybe
>>52162792
> A) Find find the dot product (or the inner product/euclidean "distance") between each point),d = np.tensordot(x,x,axes=(-1,-1))
If x is MxN, d will be an MxM array of dot products where d[i,j] = dot(x[i], x[j]).
> B) Rearrange new lists with the first entry being the coordinate in the original list and subsequent entries arranged from the "closest" to the "furthest" coordinate of all other rows in the original array.
Uh, what?
>>52162819
>unironically using Edge
10/10
>>52163030
Alright giving it a shot
>tfw all 3 my usernames is taken on FreeNode
w-what...people on IRC scare me...
>>52162938
> /dpt/ is not really the place to go asking about programming
FTFY.
>>52163077
fucking assblasted C-ucks and FP faggots think their retarded shitty meme languages are actually useful and not just a piece of shit to be wiped from some indian code monkeys ass that no one uses ina real business environment
>>52163053
> B)
> Uh, what?
Yeah: uh, what?
But it probably involves np.argsort().
>>52162823
Obviously the saviour of anime, OPM
https://github.com/jonathanslenders/pyvim/blob/master/README.rst
>>52163053
>d = np.tensordot(x,x,axes=(-1,-1))
NICE, exactly what I was looking for, thank you so much.
>Uh, what?
So for example now I have say d[1,:] which is 1xM vector of the dot products.
I want to sort this vector from smallest to the largest value. But after it's sorted I want to know it's index in the original d[1,:] vector, that information can be used to find the row entry in the original "x" array I think (I need it to feed to another function).
>>52161828
That is not a solution it is a problem.
>>52163164
map it to a tuple of its value and index (via mapi)
sort it by its value
>* Now talking on #python-unregistered
>* Topic for #python-unregistered is: Welcome to #python-unregistered! You've been put here because #python requires you to register your nickname with Freenode. For more information about registering on Freenode, ask #freenode. For more information about #python,#python-* moderation, #python-ops.
The fuck is this? Are you telling me I can't spam nigger in the chat windows?
>>52163167
If it 's simple and it works...
>>52163092
>tfw you realize the average /dpt/ poster is this autistic
Explains a lot really.
Any visual studio experts here? I'm writing a winforms project on the side for my office, but this is the first time I've used C# and visual studio, so I have no idea what the fuck I'm doing and I need some design advice.
Right now, all it does is generate documentation from a bunch of pdf and word templates, but I ultimately want to extend it to include database functionally to display different kinds of records we currently keep in a shittier format, and to generate e-mails, excel spreadsheets, etc. The problem I'm running into is that I want the program to run persistently with a low memory footprint, and whenever a new assembly is loaded, an assload of static variables are added to the stack.
It seems like my options are either to have the program dynamically load assemblies within separate appdomains so they can be unloaded without closing the program, or to have the program make system calls to execute separate command line programs externally. I feel like the second option would be less expensive and complicated, but I have no idea what the fuck I'm doing.
>>52163092
Languages literally need to take lessons from C and FP
C:
Pointers, easy manual memory allocation, low level functionality & performance, function polymorphism, syntactic macros
FP:
Match expressions, algebraic type syntax, TCO, function composition syntax (inc. currying), type inference, a unit type, generics
Anyone want to give me feedback on the first page of my C tutorial/cheat sheet
>>52163197
believe it or not, most people don't like you to act needlessly childish
>>52163226
>Right now, all it does is generate documentation from a bunch of pdf and word templates
Please stop relying on shitty tools.
>>52163181
Ok, thank you so much Anon. If was a girl I would kiss you on NYE and then some.
/</?(.{0,})>/ig
It's alright to use regex to strip HTML, right senpai?
I only ask because whenever something feels good someone always jumps in and tells me I shouldn't do it.
>>52163226
>visual studio
Off yourself
>>52163233
*macros
(though syntactic macros would be appreciated)
>>52162792
>It needs to be as efficient as possible
>Python
>>52163260
>{0,}
I seriously fucking hope
>>52162792
I'm no data scientist, but here's how I'm interpreting what you want:
For each row in the original array, you want a list containing the dot product of the current row and another row.
This list is supposed to be ordered from least to greatest, with the initial row at the front.
Performing the dot product is an Omega(n^n) operation if done poorly. There's not really any getting around that, unless you perform caching, which should bring it down to O(n(n-1)/2)
If you use binary trees for each row, the sorting operation will take O(log(n)). Of course, you will have to write a comparison operation for the binary tree that finds the dot product of the two rows, with caching.
Does that sound good?
>>52163250
It's not like I have a choice, or I wouldn't be doing this for windows in the first place
>>52163235
something so basic is not what you should need on a cheat sheet
>>52163260
You can't parse HTML with regex
But you can parse regex with HTML
>>52163233
Pointers are absolute cancer and belong in the trash. FP in general gets fantastic performance when that is the goal of the language; the right language can be faster than C in real-world, non-toy tasks in many instances.
>>52163282
I meant like array processing/optimized compiled functions instead of using for loops.
"As efficient as possible with minimum effort is how it's done in my field". I'm not a CS major.
>>52163287
Rather, the total operation should be something like O(n(n-1)/2 + n*log(n)).
>>52163164ix = np.argsort(d,axis=-1)
will return an array of integers with the same shape as d such that
d[i,ix[i,0]], d[i,ix[i,1]], d[i,ix[i,2]], ...
are in ascending order.
I.e. it contains the column indices which would sort each row.
>>52163235
Not only is it retarded to put this crap on a cheatsheet but it's also fucking wrong. Kill yourself.
>>52163302
> pointers are absolute cancer
Hello, is this Haskell I'm speaking to?
>>52163301
HTML >>>>>>> regex confirmed :^)
>>52163282
>only Python 3
>no Python 2
Seriously fucking hope you don't think 3 is the face of Python
>>52163287
>Omega(n^n)
I basically don't understand anything you said written after this. I will do some reading and get back to you. Thanks for the reply anyway.
>>52163328
Hello, is this 99.9% of the world's most destructive bugs I'm speaking to?
>>52163302
> faster than C in real-world, non-toy tasks in many instances.
Examples? Well-optimized C code that makes use of AVX/SSE is going to outperform functional code every time.
>>52163324
what is wrong about it
>>52163261
What other alternatives are there? I'm not writing C# without an IDE, that's for sure
>>52162792
Not an answer but I just realized these are piss easy to do in APLA ← ∘.(+.×)⍨∘⊂[2]
B ← ⍋
>>52163320
Ah, nice nice, this is prefect thank you.
>>52163282
>he thinks numpy is python
it's fortran and c with a python front-end, retard
>>52163357
>>>/tumblr/
>>52163375
If I learn APL will I become a wizard?
VOTE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
http://strawpoll.me/6415189
>>52163383
>someone suggests making full use of the hardware
>you send them to... tumblr
>>52162134nums = input(">>> ").split(" ") # 1 10 100 4
ints = []
for item in nums:
ints.append(int(item)) # Convert to int
ints.sort()
if len(ints) > 0:
print("Lowest:",ints[0])
print("Highest:",ints[-1])
>>52163384
It actually is "useful" as in it influences your mindset
>>52163375
I have to say this is pretty interesting, I've never heard of APL before.
>>52163355
No, I'm performance. Who's this "Haskell" guy?
>>52163282
For this, Python shouldn't be significantly slower than C, as you're performing a small number of operations, each processing a large amount of data.
It may even be faster: if you have a finite amount of time to spend on the problem, faster turnaround means that you can spend more time on algorithmic optimisations.
>>52163411
>Having single character names for SIMD vector functions is one way that APL enables compact formulation of algorithms for data transformation such as computing Conway's Game of Life in one line of code.[52] In nearly all versions of APL, it is theoretically possible to express any computable function in one expression, that is, in one line of code.
Is APL the Ur-language? It sounds like possibly the most /dpt/ language I've ever seen.
>>52163349
Omega(n^n) means, at worst, you are performing n^n operations. That basically means you're brute forcing every dot product.
This is because you're performing the dot product of each element with every other element. Therefore, n^n.
O(n(n-1)/2) is with caching involved.
If you use a Map to pair two elements with a dot product, then you have cached the calculation.
When you require the dot product again, you will receive the cached data instead of calculating it again. It's not "free", but it is immensely faster.
A binary tree is an elementary data structure where each node can point to at most two other elements. These two elements refer to a comparatively smaller and a comparatively larger element.
Inserting into this tree requires you to traverse these elements, which is an O(log(n)) operation. If you insert every element into this tree, it becomes an O(n*log(n)) operation.
This is faster than sorting a list after it's already been made, which is never smaller than O(n^2).
>>52163441
absolutely
>>52163382
I've also read this and Python(x,y) distro I'm using comes with an interpreter that is written with Cython wizardry so all my functions are compiled in C anyway.
I'm not sure how much slower it is than real C, but I'm just a ChemE as long as my optimizations aren't taking weeks per run I'm happy writing quick high level scripts, I'll leave the hardcore stuff to you CS studs.
>>52163441
The Ur language is the Ur-language.
>>52163382
> He thinks the language used to implement a library matters.
You use it by writing Python code, not by writing C or Fortran code.
>>52163445
Ah, cool, thanks for explaining that.
>>52163463
That's nearly FL level of maintainability.
>working on p2p browser application
>have to use node.js because I need to use webtorrent
>npm's fucking atrocious build ecosystem keeps breaking on this one dependency that I absolutely need to install
>I've spent all day trying to get it to build
>nothing works
>none of the suggested solutions on the internet work
How do I start contributing to big projects? All I do is kiddie script shit, I want to do something bigger than 300 lines
>>52163393
>/pol/ is winning
I'm so proud of my home board.
>>52163564
>write a python web scraper that searches github projects with a certain number of downloads for common english typos
>fix typos, submit pull requests
>within a week, have hundreds of accepted contributions to the biggest open-source projects
>>52163384
> If I learn APL will I become a wizard?
You may as well learn NumPy, which is basically just APL in the form of a Python library.
Easier to get, easier to find documentation, more heavily used (thus more libraries, more people who can give advice), better tools (e.g. IPython integration via pylab).
The only real "advantage" of APL is the geeky syntax (i.e. it uses mathematical symbols rather than ascii function names).
The fundamental idea behind both is that arrays are first-class values; you write code by operating on entire arrays rather than explicitly iterating over their elements. It can take some effort to get your head around, but once you get used to it you can be very productive.
>>52163484
and? the heavy lifting is done in those languages. i guess gnuradio, theano, tensorflow, and qt are all inconsolably inefficient because they have python front-ends?
>>52163398
Worst code I've written all year. Should have replacedints = []
for item in nums:
ints.append(int(item)) # Convert to int
withints = [int(item) for item in nums]
>>52163636
since you're clueless, shut up.
Happy new year autists.
I'm making a media player in C# - my current method for my "Library" window essentially generates a static data object for each music file uses a 3rd party lib to grab useful information out of it adds the whole thing to an ObservableCollection, then serialises the whole lot to a file in appdata.
Obviously this takes a long ass time to do for people with larger music collections, and is completely and utterly static - detecting additions to the selected root folder is nigh on impossible without generating another Library from scratch, which is just dumb. (detecting file removals is alright though, it just checks the path stored in the object to see if the file still exists).
Is there a better solution to this? Is there a way to bind a WPF form directly to that kind of thing, or am I stuck with iteration and all the shit that comes with it.
>>52163649
Theano outputs C and cuda code on-the-fly and compiles it. It doesn't use code written in C as part of its own operations and doesn't implement operations as an overlay over C code.
>>52163393
WHERE THE FUCK IS /PO/ YOU CUNTING BASTARD
>>52161828>>> import random
>>> l = [random.randint(1, 100) for x in range(10)]
>>> l
[2, 73, 89, 7, 59, 79, 10, 42, 77, 92]
>>> len(l)
10
>>> max(l)
92
>>> min(l)
2
>>>
>>52161828
Bubble sort, it's an easy algorithm to implement and it's one of the most efficient sorting methods out there.
Look it up senpai.
>>52163677
good to know but what is the point of this pedantry? it does not affect my statement.
>>52163753
>bubble sort
get out
>>52163657
poll the file modification dates, if the date is newer than the one you have cached then regen the metadata
if windows has something like inotify you can use that to avoid the constant stat calls
>>52163393
>no /trash/
>>>/trash/
>>52163806
Seems like a reasonable idea for my reading changes thing.
Still have a problem with the sheer amount of time it takes to generate a library, yeah I could make my code robust enough so it only ever has to do it once (or however many different sources a user sets).
There must be a better way to do it, that doesn't take so much time.
What language should I write a text editor in?
I sort of want to write it in python so I can learn python because it seems like it might be useful to know but I don't know if there's any point doing it and not just writingimport texteditor
Should I do it with haskell or is that just a meme language?
>>52163806
>noatime
>>52163865
Haskell is a meme language, but it might be fun to write a text editor in it.
If you want function, do c++ or C#. If you want to have fun, Haskell, F#, or Lua are your best bets.
>>52163846
>/trash/ gets added
>one day and it's nothing but pony porn
I hate this place
>>52163865
Mutability is a necessary part of editing so you literally can't write a text editor in haskell
>>52163865
Both Python and Haskell are meme languages.
The none meme languages are as follows:
- C
- C++
- Java
- JavaScript
- PHP
>>52161874
thank
>>52163890
>>52163885
I have no idea what haskell is or does by the way, I've just heard it mentioned here
>>52163910
It's essentially like programming in mathematical expressions instead of computational instructions.
You can make GUIs with it using gtk2hs.
Happy new CLISP year!
>>52163903
>java
>no C#
either both or none, they're the same language famalam
>>52163302
>Pointers are absolute cancer and belong in the trash.
Irony -- every program contains at least two pointers: the stack pointer and the instruction pointer. Inevitably, some programmer has to deal with these because no program is purely abstracted from there machine it is running on. For example, if I write a ruby program, that ruby program has to run inside of another program which uses pointers. C at least does a better job of making pointers eat to work with than pure assembly.
What you hate is not the existence of pointers, only the idea that you might have to work in a language that deals with them. All I see from your complaint is a big fat "look at me world, I cannot do native programming!"
>>52163890
Sure you can!
Just have the text in the text window be a 1:1 'graph' of the text that the user types in. Have the typed-in text be saved in an abstract buffer which then pipes 1:1 to the text window.
Boom.
>>52161946
What's the point of tail recursion when loops exist?
>>52163928
Thanks, anon.
I don't blame you for what the sneaky Jew elites do, the average Jew is alright.
I hope you fix your Palestine problem.
I want to make a foobar component. I have a lot of beginner programming experience from doing electives in uni. Basically first year stuff and a good idea on how to use std libraries.
How difficult is it to make something like this? First time doing something like this.
>>52163865
Whatever you want farn
I did one in python and it works fine
>>52163235
>1 byte is 8 bits
WRONG
>in C an address is a hex number
hex, oct and dec are simply representations
>a 4 byte int in C
Just note that int in C *may* be 4 bytes, but it is not necessary true.
>byte adrs 0x0*
I don't get this
adrs? address? nobody calls address as "adrs".
>>52163865
Text editors should ideally be lightweight. If you want to use a meme language, use Rust. Otherwise, just use C or C++.
>>52163960
It gets optimised to a loop, it can loop a lot cleaner and be more obvious.
>>52162193
Walter Bright is a self-confessed autist
>>52164004
>>1 byte is 8 bits
>WRONG
Oh my god FUCK OFF
>>52164022
look a lot cleaner*
also fuck this minute interval, literally communism
should be 30 seconds max
>>52164009
>Rust
>not Go
>>52163865
I heard JS is an excellent language for editors.
>le 2 MB faic
>>52163065
:^)
>>52163065
There Is Literally Nothing Wrong With Edge.
Happy new year, faggots.
>>52164036
I am sorry for your ignorance, but no knowledgeable person claims such an inaccuracy,
>>52164004
>1 byte is 8 bits
>WRONG
assuming we are using a desktop computer from the year 2000 or older
>in C an address is a hex number
>hex, oct and dec are simply representations
okay i will change it to simply "number"
>a 4 byte int in C
>Just note that int in C *may* be 4 bytes, but it is not necessary true.
yes that is why i said a 4 byte int
>byte adrs 0x0*
>I don't get this
>adrs? address? nobody calls address as "adrs".
that was done due to space issues
https://codeshare.io/uZRQj
Let's make something great, /dpt/!
>>52164096
You have been visited by
The Knowledgeable C Autist
100% compatibility will come to you, but only if you post "NOT PORTABLE" in this thread
More of an IT question:
How would you deploy and monitor an application to a large number of servers? Servers may be removed or added at any time.
Adding a new server should take no more than 1 minute of manual intervention.
>>52161857
Several "functional features" (lambdas, persistent data structures), like most language features, cost something in terms of performance on micro-benchmarks.
But it's a poor comparison, take a substantive program written in declarative and functional styles, memoize the functional one as far as you can, and you'll generally find the functional one is faster even if with JVM-tier overhead like clojure has.
>>52164101
>assuming we are using a desktop computer from the year 2000 or older
Should have mention that then, however since you are teaching C, you should instead say "in C a byte is at least 8 bits"
>that was done due to space issues
Use addr instead as it is much more common.
Since you are explaining something as basic, I doubt the person seeing this will know the hex notation. Moreover since it is not necessary in this case, I suggest simply removing the 0x part.
>>52163235
What are bit fields?
>>52164135
More like 'Undefined Behavior'.
>>52164193
>NOT PORTABLE isn't portable
how do i average 3 long longs in c
>>52163865
I mean if you want to write something you expect to be used for real you'll first need a compelling reason why it isn't vi or emacs. Then you'll want to implement it in C or C++ or at least substantive parts of it because mutable memory and low-level disk IO is the only way to get the level of performance we expect form editors.
If you want to have fun doing a project for the sake of learning though python would be a great choice. Haskell could be fun but you'd probably be fighting with the immutability a little bit
>>52164180
In a struct you can add :n after the field to specify the n bits a field consists of.
>>52164214
You don't, it's impossible in C.
>>52161857
C's performance is a product of 40 years of optimization on both the hardware and software end. Some computers, like Lisp machines, were optimized for functional programming and ran functional code at similar speeds to more conventional computers running imperative code, but these computers failed to ever take off and thus modern computers are great at running C/C++ or Fortran code and pretty shitty at running Lisp or Haskell code in comparison.
>>52164222
> fighting immutability
> fighting the type system
It's like these languages presume you are a retard. Maybe they were made for retards...
>>52164214(a + b + c) / 3
>>52164274
thanks, that code just got me fired
boss said it overflows
>>52164274
>implying
>>52164274
MUH OVERFLOW, says the autist
seems as if /g/ can't average 3 long longs in C
>>52164224
I know that, I was bringing them up so he'd look them up and realize that:
>In C the smallest amount of data that one can address is a byte
Was wrong.
>>52164250
>Some computers, like Lisp machines, were optimized for functional programming and ran functional code at similar speeds to more conventional computers running imperative code
Wrong
Yes they were lisp machines
no, they were not optimised for functional programming
lisp does support characteristics of functional programming but it's actually a multiparadigm language.
>>52164274(a / 3) + (b / 3) + (c / 3)
And then you have to do some other autistic shit I don't understand because memes demand it.
>>52164315
You can't address bitfields.
>>52164311(a + b + c) / 3
done
>>52164328
+ ((a%3) + (b%3) + (c%3)) / 3
>>52164329
Dude, you're dumb. Stop posting
>>52164328
Your code:
average(1, 1, 1) == 0
>averaging 1, 1, 1 correctly is "autistic shit"
>>52164342
Your code:
average(LLONG_MAX, LLONG_MAX, LLONG_MAX) != LLONG_MAX
>>52164264
>It's like these languages presume you are a retard.
You mean Haskell? I'm not a haskell shill by a long shot but I think that's pretty much the last thing that's wrong with it, if anything it probably assume a little too much of its users.
Immutability is a great idea, it's just not every problem in the world is 100% amenable to it. Many, probably most, are though.
>>52164363
Show me how would you address bitfields, faggot.
They are not even considered an object by the C standard.
>>52164264
by what stretch of your imagination did you come to the conclusion that writing Haskell code requires fighting against the type system. If anything, that sounds like an accurate description of Java.
>>52164319
They had more logical mappings for Lisp primitives in their assembly languages, like working with pairs, symbols, or anonymous functions rather than focusing on numbers or the likes. While Lisp is very multi-paradigm, it is much closer to being functional than the languages other computers were optimized for (Fortran, C, etc.).
>>52164129#define long long
//long long can store more data than just long
int average(long long x, long long int y) {
int primary_integer_buffer_x = x;
int primary_integer_buffer_y = y;
int secondary_integer_buffer = primary_integer_buffer_x + primary_integer_buffer_y;
int tertiary_integer_buffer = secondary_integer_buffer / 2; //logic is only a number
int final_integer_buffer = tertiary_integer_buffer;
return final_integer_buffer;
}
holy shit this is gold
Sup sepple kids, which constructor is the most correct one if you want to perform some additional setup on the object:class Foo {
public:
Foo() {};
void bar(std:string);
// one
Foo(std::string s): Foo() {
(*this).bar(s);
};
// two
Foo(std::string s): {
return Foo().bar(s);
};
};
>>52164329
True but the cheat sheet almost feels as if he's trying to say the small object in C will still take up 1 byte. Which is false
>>52164370
I forgot your meme language isn't dynamically typed.
>>52164402
I did not expect /g/ to be able to solve the riddle anyway
>>52164387Foo(std::string s) : Foo() { bar(s); }
>>52163235
The smallest data type in C is char. It is guaranteed to be the size of a byte, but the size of a byte is not necessarily 8 bits. In C, the number of bits represented by a char is defined by the constant CHAR_BIT, which is defined in the header limits.h. With regards to the size of the other integral types, the following inequalities describe their sizes:
8 bits ≤ char
16 bits ≤ short
16 bits ≤ int
32 bits ≤ long
64 bits ≤ long long
sizeof(char) ≤ sizeof(short) ≤ sizeof(int) ≤ sizeof(long) ≤ sizeof(long long)
Pointers/addresses are integer values which store the location in memory. Their size will vary from system to system, and may even vary between what is being pointed to (i.e. a function pointer may be larger than a pointer to an integer), although they are usually the same size. Common pointer sizes are 32 bits and 64 bits.
With regards to how integers are stored in memory, this is also varied from system to system. Let us assume foo is a value declared as follows:int32_t foo = 0x12345678;
Let us also assume that foo is located at address 0x400000. In a big endian system, it would be placed in memory as follows:0x400000: 0001 0010 (0x12)
0x400001: 0011 0100 (0x34)
0x400002: 0101 0110 (0x56)
0x400003: 0111 1000 (0x78)
On a little endian system, however, it would be placed in memory like this:0x400000: 0111 1000 (0x78)
0x400001: 0101 0110 (0x56)
0x400002: 0011 0100 (0x34)
0x400003: 0010 0001 (0x12)
Computers running IA-32 or AMD64 (a.k.a. x86) CPUs will always use little endian models. Computers with SPARC or POWER/PowerPC based CPUs (prior to Power8) will always use big endian models. Computers using ARM, POWER8, or MIPS may vary between CPU implementations. This is called "bi-endian". ARM based computers may also use a third endianness called middle-endian. Data transferred through network packets is always in big endian format (called "network byte order").
Hope that helps.
>>52163903
>Javascript
>Not a meme language
Wew there lad
>>52164387
Neither, the correct constructor would be:Foo(std::string s) {
this->bar(s);
};
>>52164383x++ += x++ + ++x; //JUST FUCK MY SHIT UP SENPAI
wow
>>52164432
>one of the most used language in the world
>meme
>>52164423
Slight correction on the little endian notes, address 0x400003 should be:0x400003: 0001 0010 (0x12)
Typo.
>>52164420
Wew, that's surprisingly easy.
Thanks.
>>52164445
Noticed that as i pressed submit. The approve seemingly works as advertised and is shorter/clearer.
Daily reminder that a bool is not guaranteed to be one byte in C
I'm playing with my HP 48GX.
>>52164490
>not guaranteed
so there is a possibility?
>>52164503
Monads are so cool.
>>52164506
>>52164135
NOT PORTABLE
>>52164400
The smallest addressable object in C will take 1 byte exactly.
>>52164370
>>52164410
Fine, what happens if you plus 1?(a / 3) + (b / 3) + (c / 3) + 1
I'm hoping for a meme miracle.
>>52164529
average(0, 0, 0) = 1
see here
>>52164357
>>52162245
Based D
>>52164379
>no reply
How many dicks did you put in your ass >>52164363?
>>52164490
Yes, and? If it would be faster on a particular ISA to test values that are say, 4 bytes, than one that is 1 byte, then a bool should be 4 bytes on that architecture. If one needs values to be compact, one should use char, or use a bitfield.
For the record, it is also perfectly valid for a char to be 500 bits.
what's the significance of doing:fetch("/some/url").then(function(response){
return response.text();
}).then(function(text) {
// do something with text idk
console.log(text);
});
with the new Promise™-based Fetch API™ as opposed to the more straightforward and direct:fetch("/some/url").then(function(response){
console.log(response.text());
});
I am not pulling this out of my ass:
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
I'm legitimately curious why the examples are like that.
>inb4 the blame javascript first crowd
>>52164423
Neat anon, thanks for the quick lesson.
>>52164606
Stop trying to make fetch happen.
>>52164619
I still watch that at least once every year
just watched it yesterday
>>52164616
>Ruby !!UOnz2YE1hdj
>anon
To anyone with npm installed:
could you please runsudo npm install wrtc
and see if it's able to build without errors? I'm 99% sure that the package is broken, but I'm only able to test it on Mint and Ubuntu at the moment.
>>52164660
tripcodes ruin everything
>>52164606
It's useful if response.text() is asynchronous for some reason. Presumably grabbing text from a response object when its promise is resolved is not so the example is dumb but the chaining style is useful when you need to take multiple async actions in series
>>52164660
>not having the anonymizer on
>>52164606
This is what happens when JavaScript becomes a meme
>>52164716
>making ignoring and filtering tripfaggotry harder
>>52164660
My bad.
>>52164616
No problem, mate. Computer architectures can be some seriously interesting shit, and the basics of it are definitely on every computer scientist's "must know" list.
>>52164660
I honestly don't mind when people call me Anon anyways. It's no big deal.
>>52164745
>computer scientist
Computer "science" is not a science.
>>52164745
>computer scientist
"Computer" science has nothing to do with computers
>>52164665
I would of I was home. Npm doesn't care about the quality of it's packages. I've met tons of broken packages. I'd move on.
>>52164803
It's non-negotiable, though. It's a dependency for webtorrent on node.js and I can't complete my project without it.
_write fr 1 obfrob OB JUST OB obfrob 4 ob FROBOB
r8
>>52164745
Computer so-called 'science' actually has a lot in common with magic
>>52164830
"reddit will love it"/"10"
>>52164846
>everything I don't understand is magic
wew
>>52164830_write fr 3 obfrob average fr fib fr fib fr fib fr fib fr fib fr fib fr average fr fib fr fib fr 1 ob obfrob fib fr 3 ob ob ob ob ob ob ob ob ob ob obfrob 1 ob FROBOB //trust me, we lisp now - I thought /lgbt/ was gay.
bloody hell anon
>>52164830
>>52164857
A ^FROB^? What's that?
>>52164867
New thewd faggots
>>52164851
>dividing by a string
>>52164865void FROB(char ARE_FROBQ, char* ARE_FROBW) { //stop it pajeesh
if(if(if(if(if((int)ARE_FROBQ == (long)ARE_FROBW))))) {
return *void;
} else {
#define FROB int
#define frob main
#define fr (
#define ob )
#define Fr {
#define oB }
#define OB "
#define FROBOB ;
#define obfrob ,
#define OBfrOB :
#define PLEASE GOD NO
Ob
I did it first anon
NEW THREAD
>>52164882
>>52164882
>>52164882
>>52164875
>not able to overload operators
>>52164888
step up your fucking game man>>52164879
>>52164889
late
again
by a minute and 10 seconds
>>52164879
Ah yes, I see
>>52164898
>i don't know what a field is
>>52164773
Yes, and?
>>52164802
And yet every serious computer science curriculum covers computer architecture. Maybe it has something to do with the importance of understanding how one's tools work...
>>52164846
Magic doesn't exist. Are you saying that computer science does not exist either.
>>52164928
>Magic doesn't exist
>he doesn't know about magic
embarassing
>>52164856
He's just paraphrasing that SICP lecture.
https://www.youtube.com/watch?v=aHk42kDwesM
JANITOR
>>52164867
>>52164882
WE HAVE A PROBLEM
>>52164955
I opened that song to hear just a few seconds before you posted it. What a coincidence.
Also, I think you wanted to post this https://www.youtube.com/watch?v=2Op3QLzMgSY
>>52164699
Thanks for the insight, I'll keep that in mind.
>>52164490
>implying this matters
>>52166761bool x[100]; /* this takes 9 GB */
>>52166783
jboolean x[100]; /* this takes 100 B */