Previous thread: What are you working on, Sup Forums?
Previous thread: >>55946704
I'm working on an ODE solver in Haskell.
O SHIT WADDUP
>forgetting to post a link in the old bread
I covered your ass this time, OP
Zero configuration chat client
>bread
you have to go
Why is nobody posting
posting what?
because
hey user what term is that ?
row polymorphism
xth for VC++ being shit
as in terminal? zsh with the agnoster theme for oh-my-zsh
Cool
What is the most difficult part of it?
What can I do now that Windows can use gcc?
>title in name (unsearchable in catalog)
>didn't link to here from the old thread
sure is summer
rm -rf %WINDIR% --no-preserve-botnet
I'm building an imageboard in C#/asp.net webforms.
Implying there isn't eternal summer now
Repostan
typedef struct _Data {
uint16_t a;
uint8_t b;
} Data;
std::vector src;
std::vector dst;
How would I go about copying the contents of src to dst with std::copy and iterators?
Fuck, it's supposed to be an uint8_t vector instead of char
First of all, in C++ you don't need to typedef structs like that, this is fine:
struct Data {
uint16_t a;
uint8_t b;
};
Second, what exactly do you want to get into dst? Data.a? Data.b? Is the char type a typo?
You would have to create your own iterator types.
I see, thanks. I just want the memory representation of the struct array as bytes in the dst vector.
memcpy(src.data(), dst.data(), src.size() * sizeof(Data));
Works fine, but I wanted to do it with std::copy. Not sure how.
My first language that I finished a tutorial series on
Now I'm learning python (will learn NumPy and Pandas later), and after that I'll learn R
Or you could stick with C++ as if you have a pair
>after that I'll learn R.
I wouldn't bother. You can do most of your statistical work with Python. It would be more beneficial for you to dedicate your time to learning skills rather than languages.
And now I switched the source and destination. Well, I guess it's understandable anyway.
>wanna learn C
>can't decide what editor/IDE to use
So something like this?
std::vector src{};
std::vector dst{};
dst.reserve(src.size() * 3); // Pre-allocate memory
std::transform(src.begin(), src.end(), src.begin(), [&dst][const Data &data] {
dst.push_back(data.a);
dst.push_back(data.b & 0xFF);
dst.push_back(data.b
>learn R
That will be an interesting afternoon, why talk about it?
Rscript script.R
That seems really convoluted, maybe I'll just stick to memcpy with POD structs.
Notepad. Don't be a faggot.
Very true, as for skills I'm learning statistics now
>tfw Casella & Berger Statistical Inference gives me no intuition
Now I'm reading pic related, I know it's a meme book but it's good at explaining stuff
It would be really stupid for me to disregard python and R. Note that I'm not a code purist, I'm just a kid who wants to make money
See above, I don't know nearly enough statistics to make use of R really, if you have resources to recommend I'll be extremely happy
The simplest thing is just to use a for loop:
dst.reserve(src.size());
for (auto data : Data) {
dst.push_back(data.b);
}
..should be for (auto data : src)
>not auto&
Thanks but I'll just use memcpy, I'd rather not iterate over tens of thousands of entries.
>not const auto&
Data is 24 bits, while a pointer is 64 bits. Won't make a difference either way.
>const
pussy
I love these edits.
>letting anyone modify your state
slut
They should be the same performance-wise, or at least the difference will be negligible. memcpy isn't magic.
the beauty of R is that you don't really have to know a lot about statistics to use it as a statistics tool.
Eg, if you want to test if the variance is equal between two populations, you could use var.test
You can see that it is a F-test, and if you knew about statistics, you would know if this is the right test based on your data, but you can't really blame R for not teaching you statistics.
As for reading material, you could pick a book on R, learn how to use the 4 data structures, but you might as well pick up a book that teaches you statistics as well.
For the packages, use:
?package
or
[code
??search_term
Vim + gcc faggot
>thinks declaring things const means that they cannot be changed
wew lad
I suppose. Seems like this works, though.
std::copy(src.begin(), src.end(), reinterpret_cast(dst.data()));
Guys, help me shitpost. I'm all out of inspiration.
>tfw non-american keyboard layout, making vim shortcuts really inconvenient
I knöw thät feel
I'm not blaming R, I'm saying that Im not ready for R yet.
As for f test, student's t test etc. etc. I had that in my orientation econometrics class, and I went through the motions (in STATA, not R) but I don't know what any of those mean. at all.
I just picked up the manga book, and that explains stuff really well. I now understand what a z score is.
>but you might as well pick up a book that teaches you statistics as well.
Such a book would be ideal, preferably one that goes in depth like Casella & Berger (the GOAT book, but too incomprehensible for me now)
protection is only 99% effective :^)
So get an American keyboard. You should be programming in US English.
you should try doing that fizzbuzz again jesus...that's bad
I already have the language packs installed, just takes a while getting used to.
Ko-chan~!
wg := new(sync.WaitGroup)
wg.Add(1)
go func(){go func(){go func(){defer wg.Done()}()}()}()
func (c *Client) callback(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
topic := q.Get("hub.topic")
switch q.Get("hub.mode") {
case "subscribe":
c.l.RLock()
s, exists := c.topics[topic]
c.l.RUnlock()
if !exists {
http.Error(w, "Unexpected subscription", http.StatusBadRequest)
return
}
now := time.Now()
lease, err := strconv.Atoi(q.Get("hub.lease_seconds"))
s.l.Lock()
s.verifiedAt = now
if err == nil {
s.lease = time.Second * time.Duration(lease)
}
verify := c.verifycb
s.l.Unlock()
if verify != nil {
go verify(topic, time.Second*time.Duration(lease))
}
w.Write([]byte(q.Get("hub.challenge")))
case "unsubscribe":
c.l.RLock()
_, exists := c.topics[topic]
c.l.RUnlock()
if !exists {
w.Write([]byte(q.Get("hub.challenge")))
} else {
http.Error(w, "Unexpected unsubscribe", http.StatusBadRequest)
}
default:
c.l.RLock()
s, exists := c.ids[q.Get("c")]
c.l.RUnlock()
if !exists {
http.Error(w, "Unknown subscription", http.StatusBadRequest)
return
}
h := sha1.New()
body := new(bytes.Buffer)
_, err := io.Copy(io.MultiWriter(h, body), r.Body)
if err != nil {
return
}
hash := hex.EncodeToString(h.Sum(nil))
s.l.Lock()
_, seen := s.history[hash]
s.history[hash] = struct{}{}
handle := s.handler
s.l.Unlock()
if seen {
return
}
r.Body.Close()
r.Body = ioutil.NopCloser(body)
handle(r)
}
}
unsigned int
CapabilityIndex::put(std::string cap, void *ownerdata)
{
std::shared_ptr entry;
if (highest_bit == 0)
return 0xFFFFFFFF;
if ((entry = find(cap)) != NULL)
{
entry->orphan = false;
return (1 value);
}
entry = cap_dict[cap] = std::make_shared(cap, highest_bit, ownerdata);
highest_bit++;
if (highest_bit % (sizeof(unsigned int) * 8) == 0)
highest_bit = 0;
return (1 value);
}
Just some advice you should probably use a lower tab width. C++ with microsoft style 8 space tabs is a bitch to work with.
yeah, probably... I use atom-beautifier (uncrustify) to get it
Once I figure out how to lower it I'll make it 4
Slightly off topic, but has anyone taken LSD (or similar) while programming? Did it help?
>Did it help?
I almost guarantee that it would not.
I wrote some of the most incomprehensible code I've ever written after taking shrooms. It worked, but I still have no idea how.
Which functional languages are faster than Haskell?
OCaml
LSD and hallucinogens make your brain fire rapidly. Whatever you write under the influence is a result of your subconscious knowledge showing itself .
C++ is a mental black hole by itself
it's almost impossible to learn to read, hard to learn to write in passable quality
only people in their 50s who've had no lives *kinda* know C++
I did a bunch of project euler problems while on LSD because I thought I forgot how to program
antichess AI
and they just keep adding to the language more and more complexity because they are 60 now and bored
Lisp, if you count it as functional.
working on an app to listen to r/a/dio so I can listen to anime music while i read manga without getting my laptop
what's it called (is it on the app store yet?)
Writing a game in Unity and I'm getting 30ms GC stalls every minute or so on mobile. How do I debug memory leaks with C#?
It's called radio, not on the store yet. Give it a week or two. Will release android too shortly after. Opinions and requests welcome.
UB doesn't count
I'm going to learn C today.
did you send it to whoever owns r-a-d.io ?
>memory leaks
But that's the point. C# doesn't memory leak because you GC.
What you're asking is 'how can I not be terrible at using memory'.
Written a triangle voxelizer. It was simpler than i originally thought it would be.
This.
But should I learn D instead? I've heard it's better but I'm afraid that the community has ideas of 'useful abstractions' rather than being smart and letting you write code efficiently. Nobody can write generalised useful abstractions aside from very simple things like datastructures and associated algorithms.
#include
void my_fn(const int *a, int *b)
{
printf("%d\n", *a);
++*b;
printf("%d\n", *a);
}
int main()
{
int a = 10;
my_fn(&a, &a);
}
Yes, pretty much. At least in C I can run valgrind and see what's going on (or just ignore it because leaking a few megs of memory an hour doesn't cause the fucking program to msis its frame timing window)
>or just ignore it because leaking a few megs of memory an hour
Absolutely disgusting.
Manage your shit properly.
I'm sure there's memory profiling tools that you can use that point you to where the to-be-freed memory is allocated. Somewhere.
Is pointer aliasing UB?
No. Unless they are restrict pointers, which C++ doesn't even have.
>D
unfortunately D hasn't become popular in any field and that sort of thing can take many years
a language needs to have useful libraries and a huge community of users and devs, otherwise it's a waste of time
if you write code like that you suck ass
Should I save this pic in my g folder or my newgame folder?
ordered my new toothpaste
its grape flavored and has xylitol in it
nice
Enjoy your possible gas, liver issues, and a host of other risks (Cancer, Diabetes, Deperession, etc).
Why do people care for this? Manga was pretty bad and it has practically nothing to do with software development and frankly it's not gamedev either. Its a person doing 3D models.
how is "learn python the hard way"?
Using a minimum assumption that "few megs" is >= 2, I calculated that leaking >= 2 MBs an hour would come out to:
2^20 * 2 B/h = 2,097,152 B/h
= 34,952 B/m
= 582 B/s
Every second you leak >= 582 bytes of memory. On 99% of implementations (1% to account for meme architectures/compilers) that's losing a pointer to 582 chars every second. How did you manage to be the worst programmer and/or be so pajeet that you don't care about such a significant loss.
From a relatively small amount of toothpaste?
none
what's wrong with using php for views vs some shitty javascript mess
Haven't used it myself, but I have yet to see a single good thing said about it.