What are you working on, Jow Forums?
Previous thread:
What are you working on, Jow Forums?
Previous thread:
Other urls found in this thread:
automatetheboringstuff.com
interactivepython.org
wiki.osdev.org
dl.acm.org
ieeexplore.ieee.org
ieeexplore.ieee.org
en.wikipedia.org
twitter.com
First for Java
nth for nim
Why haven't you learned Haskell yet, Jow Forums?
good image OP
>making a thread as soon as bump limit gets hit
I wonder if the bowsette poster is the same person who would spam hime years back
what use case does hasklel excel at?
Why does strncpy always write n bytes? Wouldn't
char* copy_string(char* dst, char* src, size_t write_max)
{
size_t write_count = 0;
while( *src != 0 && ++write_count < write_max )
{
*dst++ = *src++;
}
*dst = 0;
return dst;
}
be much faster, especially as potential string length (n in strncpy) becomes large?
more than one himeposter
DSLs for parallel and distributed programming
Development time and program correctness.
it's a general purpose programming language and it excels at most things
Except memory usage and binary bloat.
yes
And cross-compilation.
shitposting
I don't buy that until someone posts benchmarks of such DSL vs MPI
uwu
based sepples
why "by"
>I write code that looks like shit so I can save myself a couple well-written lines doing something else
Maybe if it was efficient or something but it's not. Use C++ tools when they make the easier to read or understand, not harder
Like this
using System;
using System.Linq;
namespace DivisibleSumPairs
{
public class Program
{
public static void Main()
{
int k = int.Parse(Console.ReadLine().Split()[1]);
int[] list = Console.ReadLine().Split().Select(int.Parse).ToArray();
Console.WriteLine(DivisibleSumPairs(list, k));
}
static int DivisibleSumPairs(int[] list, int k)
{
int count = 0;
for (int a = 0; a < list.Length; a++)
{
for (int b = 0; b < list.Length; b++)
{
if (a < b
&& (list[a] + list[b]) % k == 0)
{
count++;
}
}
}
return count;
}
}
}
To paraphrase my post in the last thread: the C stdlib is just unbelievably shittily designed, and strncpy() is a prime example of this.
Anyway, sounds like you want strlcpy()
what does the "unit_type" do? also that unit is the same as just feet since a radian is unitless
>a radian is unitless
radian is length per length, making it unitless
god, C# is gross.
Thank you!
>for (int a = 0; a < list.Length; a++)
> {
> for (int b = 0; b < list.Length; b++)
> {
> if (a < b
*throws up*
*throws up*
post where you use it
What about it? I could have written it in a better but less compact way.
idk couldn't think of anything other than "times"
there will be wrappers for powers of course
believe it or not there is a use case for this
and I don't know what you mean by not efficient, syntax or performance?
radian is a dimensionless unit, there's a difference
The word you're looking for is dimensionless. It has a unit, the unit is 1 rad.
encasing everything in a class in a namespace.
the two loops, the formatting.
what's the use case?
APIs shared between well-established organizations who prefer working in their chosen units for a given application and can't be made to change, but where messing up the units could have significant financial impact.
Or just any code worked on by more than three people; the number of fucking times I've seen degrees passed to sin().
Wrapping everything in a class and a namespace might seem nonsensical for trivial stuff like this or Fizzbuzz but it's really not an issue and actually makes sense when you take the OO nature of the language into account. It does have its pros and cons, like everything else.
static int DivisibleSumPairs(int[] list, int k) {
int count = 0;
for(int b = 0; b < list.Length; b++)
for(int a = 0; a < b; a++)
count += ((list[a] + list[b]) % k != 0) ? 0 : 1;
return count;
}
M : [A] -> Type -> Type
return : B -> M [] B
join : M xs B -> M ys B -> M (xs ++ ys) B
mapM : (f : (x : A) -> M [x] B) -> (xs : [A]) -> M (map f xs) [B]
Hmm.
so something that can be done in a more readable manner
join : M xs (M ys B) -> M (xs ++ ys) B
Silly me, mixing up natural transformations and functions in the same type.
I'm just exercising the library, I don't expect it to be used like this
Huh, it says strlcpy is very similar to snprintf. Are you familiar with snprintf? I have a very hard time imagining how such a useful and relatively complex tool is not much, much slower than the more simple stuff (cpy, cat, etc), for simple stuff. It is, isn't it?
I'm sure it can be faster when cat'ing multiple strings or in other situations.
mapM : ((x : A) -> M [x] B) -> (xs : [A]) -> M xs B
Ugh.
just call it "multiply" fagtron
How do I into Python. Looks like a fun scripting language. What's a good resource for it?
You know, what I'm done. You know what I mean.
if you don't know nothin' about programming
interactivepython.org
If you're already a programmer, just download anaconda or miniconda with Python 3 and use Google every time you don't know how to do something.
If you're an IDE boy, use PyCharm and always use Python 3's type annotation features.
no
How does one start programming an operating system from scratch?
Thanks guys!
Google "strong typing"
I don't think the Scratch language is sophisticated enough for that
>strong typing
Thanky, fren.
Who put you up to this.
Strong typing is a meme. It hasn't been proven conclusively to actually improve program correctness or productivity.
the idea that you can place autistic restrictions on a language to prove certain facts about programs written using it is a relatively recent one
at the very least if you're not using C#'s unsafe blocks then you'll at least never run into pointer issues.
That's because the places where it would help can't be bothered to spend the budget to convert their legacy codebases.
I'm never going to stop shilling strong typing.
t. 150 buffer overflow and data races per line
i'm putting you up
this is a robbery
>static typing makes me write less bugs and be productive, r-right guys?
>bugs are features!
>let's attack a strawman because I have no good arguments!
NO GOOD MORNING. FUCK YOU. BAD MORNING.
SHOOT ME.
You are like a baby, watch this
static int DivisibleSumPairs(int[] list, int k) =>
Enumerable.Range(0, list.Length)
.Select(x => Enumerable.Range(0, list.Length)
.Select(y => new Tuple(x, y)))
.SelectMany(x => x)
.Where(pair => pair.Item1 < pair.Item2
&& (list[pair.Item1] + list[pair.Item2]) % k == 0)
.Count();
>write less bugs
yes
>be productive
lol no but it's fun as fuck
>hatsune
Stop lowering the thread's quality.
You should learn Scheme and ML first.
You can't stop me Varg, you'll never be my real dad!
install Shen instead.
You're the one claiming that static typing improves productivity and correctness. Here are some sources to support my claims (You haven't provided any arguments, let alone sources).
dl.acm.org
ieeexplore.ieee.org
ieeexplore.ieee.org
>teleports behind you
>it's already a good morning
nigger
>pay or sign in to read this
yeah, i'm gonna need non-trash links.
I guess you lost the argument then. Stay mad.
you dont win arguments by posting studies behind a paywall
You never provided an argument or sources. I guess I win by default then.
#include search starts here:
/usr/include/c++/7
/usr/include/x86_64-linux-gnu/c++/7
/usr/include/c++/7/backward
/usr/lib/gcc/x86_64-linux-gnu/7/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
Can somebody tell me where are stored and defined the directories and search order for the default includes in gcc for the C and C++ compilers? I get the above from the g++ but I cant find the source.
Jehovah's Witnesses don't celebrate Halloween because they don't appreciate random people coming up to their door.
worst /dpt/ in recent memory
post eloquent C please
>post eloquent C please
here's the complete list
What's the easiest way to determine if a file is a music file in C? I could just compare extensions but that just sounds hacky and bad. The only other way I know would be to ensure it has an audio stream via libav/ffmpeg. Is that as slow as it sounds? Is there a faster/better way?
Thank God this is a christian board then
#include
int main(c, v)
int c;
char** v;
{ return atoi(c[1]); }
why is comparing extensions hacky?
import turtle
x = 0
while x < 100:
x = x + 1
turtle.forward(x)
if x % 3 == 0 and x % 5 != 0:
turtle.right(90)
elif x % 5 == 0 and x % 3 != 0:
turtle.left(90)
elif x % 5 == 0 and x % 3 == 0:
turtle.circle(x)
Here is a neat C trick.
#include
#define calculate(...) \
calculate_f((calculate_s) { .a=1, .b=1, .total=0, __VA_ARGS__})
typedef struct {
int a;
int b;
int total;
} calculate_s;
int calculate_f(calculate_s t)
{
return t.total + t.a * t.b;
}
int main()
{
printf("%d\n", calculate(.a=12));
printf("%d\n", calculate(.b=10, .total=10));
return 0;
}
because you can rename file extensions to whatever you want
file format specs should have information telling you what their signature or header should contain
steam it in and do some FFTs to ensure there are no sharps or flats if you meant C Major.
strong typing > weak typing
This nigga
Science Says You're Wrong
>if a file is a music file
All files are music files
Explicate.