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



Thread archived.
You cannot reply anymore.




File: meido computer.jpg (227 KB, 850x1190)
227 KB
227 KB JPG
old thread: >>67993819

What are you working on, /g/?
>>
File: mov zig.png (118 KB, 4824x1527)
118 KB
118 KB PNG
for me, it's zig
>>
File: 1470792067398.png (36 KB, 268x237)
36 KB
36 KB PNG
Employed Haskell programmer here and reporting in
>>
that scoliosis though
>>
made any progress today lads?
>>
File: 1538941916005.jpg (413 KB, 2048x1536)
413 KB
413 KB JPG
>>68001709
For me, it's nayeon

I mean gb emulator
>>
text editor poll continues
https://www.strawpoll.me/16604780
>>
File: gudako.webm (933 KB, 720x1280)
933 KB
933 KB WEBM
I've been gone from computing for 6 months.
Has webdev gotten any easier or is it just as hellish as ever before?
Has webassembly killed miles of JS framework abstractions yet?
>>
>>68001808
>text editor poll continues
>https://www.strawpoll.me/16604780
My favorite text editor is not the one I use the most :(
>>
>>68001733
why would I use it over rust or C++
>>
>>68001839
>webdev gotten any easier
nah fampai, we have loads more web apis now

>Has webassembly killed miles of JS framework abstractions yet?
nope, still young, but will get more powerful as it allows dom manipulation and other things in the near future. It has opened us up to a whole new world of emulation though
>>
>>68001886
you wouldn't, he's just shitposting.
>>
I've always wanted to use Rust but it's pretty strict. Last evening I was thinking of dynamically creating GtkRadioButtons and how to collect the selected RadioButton in the group in O(1)

With D I created a tuple of int and array of strings; Then for each of the string in the array I created a delegate that sets the int of the tuple to the index of the string when clicked.

D let's me do that, but Rust would fuck me in the ass so hard I would probably get a rectal trauma.

If you are iterating through a vector of strings by the reference of the tuple you will not be allowed to take a second mutable reference.

It's 7:40 AM which means I am half asleep while writing this but all I wanted to say that GUI in Rust is very painful, at least gtk-rs is.
>>
File: unknown.png (394 KB, 1000x494)
394 KB
394 KB PNG
JavaScript rocks!
>>
>>68002021
WTF I love JavaScript now!
>>
>>68002021
>Eat
>Lemon and
>Masturbate
>>
File: 1377363625357.jpg (936 KB, 1041x1509)
936 KB
936 KB JPG
>>68001762
I'm moving backwards.
>>
>>68001840
why don't you use the most the editor you like the most?
>>
>>68002016
not saying rust is good, but a good programmer learns to adapt to the language. But i agree, Rust isn't a language you adapt to, it's a language you're forced to conform to. Which in a way i'm not completely against. Maybe if Rust's syntax wasn't so ugly, you'd be more willing to get railroaded at every line.
>>
>>68002072
>why don't you use the most the editor you like the most?
I like emacs but I'm too dumb for it, so I've used Vim for the last 10 years instead
>>
im doing haskell and I don't understand how this data type only needs one type. Like how it takes two types A B but functor only takes A
module EitherMonad where
data Sum a b =
First a
| Second b
deriving (Eq, Show)

instance Functor (Sum a) where
fmap f (First x) = First x
fmap f (Second x) = Second (f x)
>>
>>68001709
Mahoro is my girlfriend!
>>
>>68002230
partial application of type constructors

Sum has the kind
* -> * -> *
. Just likes functions, it exists in curried form and consumes two arguments of concrete types before yielding another type, which has a kind of just *.
Functor has the kind
(* -> *) -> *

If you partially apply Sum, then you have
Sum a :: * -> *
.
Presto, now it can be used as the argument to Functor.
>>
>>68002230
It's a functor in the second parameter only.
EitherMonad is not the functor. (EitherMonad a b) is not the functor. (EitherMonad a) is.
>>
>>68002371
thank you, that makes sense
>>
File: 1411319683164.gif (1.23 MB, 1280x720)
1.23 MB
1.23 MB GIF
Holy shit, I just solved a problem with math and now I'm seeing patterns, it's like the planets have aligned. I didn't know math could be so interesting.
>>
>>68002230
g(x,y) := x*sin(y)

if f is a function of one variable, define the functional
Integ(f) := integrate f(y) dy from y=4 to y=5

now if a is some value of the type that x has, then
Integ(y mapsto g(a,y))
still makes sense
>>
Anons, what's the best way to make an array of generics?

I tried:
R[] r = new R[n];

but that doesn't work. I can't use {n1, n2, n3} to initialize my array because I don't know what the size it will be.

>>68002497
Are you high?
>>
>>68002655
In C++ this is just
R r[] = {n1, n2, n3};
>>
>>68002696
it's in java. and I don't know what size the array needs to be so I can't initialize it that way.
>>
>>68002655
in haskell this is just

r :: [R]
r = [n1,n2,n3]
>>
>>68002734
the annotation is unnecessary
>>
I need to do some data wrangling (merge, aggregating, dropping columns, date parsing...) on a large number of large CSVs (~5 to 10 gb each)
What's the best way to proceed?

> R seems out of the question as it sucks at handling larger than RAM datasets
> Spark sounds nice, but I've never used it and it looks like there's quite a lot of overhead
> Dask could do the job, but it seems kinda slow

Any better ideas ?
>>
>>68002774
useless annotation for a useless language.
>>
>>68002833
Parse them into a PostgreSQL database
This is what it's made for
>>
>>68002774
ironic considering C++ programmers love annotating their function type now at the top and then new lining the definition.
>>
what are some novice level projects I could do that highlight some of the unique features of c++ as compared to higher level languages like python
>>
>>68002717
Use ArrayList
>>
Can you guys recommend me any book or website to learn Java correctly ? I already have experience in C (I would say I'm decent). I'm currently reading "Core JavaSE9 for the Impatient" it's pretty nice but the exercices are shit and I have difficulty understanding them.
The best would be something that goes straight to the point without wasting my time (it's extremely precious).
>>
>>68002946
>to learn Java correctly
strictly speaking you can't, in Enterprise Java-land you're a permanent fuckup, the people with more experience just fuck up less.
>>
>>68002962
this.
>>
>>68002962
>>68003009

Oh fuck me then, so every java book is a pile of shit ? They all pretend to teach you "the right way"
>>
>>68003084
There's a lot of money in education.
Most books get it wrong.
There are few languages that have a "holy grail" book, C, C#, Lisp being the ones I can remember off the top of my head.
The rest are left to squander and pick up the pieces from StackOverflow, Algorithms textbooks, and the Gang of Four.
>>
What can I do with XML?
>>
File: soy_npc.png (178 KB, 1276x1151)
178 KB
178 KB PNG
>>68002016
You shouldn't use Rust, it's a onions lang.
>>
>>68003268
>m.LetIn()
even OOPsies wouldn't make this a method of migrant
>>
File: browser.png (49 KB, 928x733)
49 KB
49 KB PNG
Working on muh gui, image shows a nash equilibrium poker strategy for the preflop round.
>>
>>68003314
that doesn't look readable at all
>>
>>68003263
https://en.wikipedia.org/wiki/XML#Applications_of_XML
>>
>>68003263
What can you do with XML that you can't do with JSON or YAML?
>>
File: xml.png (26 KB, 496x320)
26 KB
26 KB PNG
>>68003263
nothing good
>>
File: 1537902533781.jpg (806 KB, 1280x720)
806 KB
806 KB JPG
>>68002925
I use arraylist in the method but it has to return an array. I don't know how to convert ArrayList<R> to R[].
>>
File: build.gif (350 KB, 1154x843)
350 KB
350 KB GIF
>>68003328
Yes, you are right I guess. I worked more on the basic functionality, I think the look can easily be improved.
The gui has itself a ton of logic, like mapping poker card indexes to simplified grid, enabling and disabling cards based on the selected card suits and so on so I started with that.

I think some other widgets, like the board selection already look much better.
>>
>>68003427
Learn how to use Google
It's literally just
.toArray()
>>
I've been working on python for about 5 months now, would it be a bad idea to switch to another language like c++? Should I just stick with python for longer? I still feel like a novice.
>>
>>68003397
Come on, XML is simple to understand.
>>
>>68003455
What do you code for? Python is a small project, practical solution programming language that scales up poorly, if it fits your needs there's very few good reasons to switch to other languages
>>
>>68003451
learn how to use google.
the casting back doesn't work if the method returns R[]. Java won't let me caste from an Object[] to R[].
>>
>>68003369
JSON and YAML use strings, arrays, lists, and many object types explicitly.
You don't need to know about lists or strings if you're parsing XML, it's as if it was using symbols ,it has a very LISPY feel.
>>
>>68003487
God Java is such a shitlang, do yourself a favor and use C#
>>
>>68003487
R[] foo = bar.toArray(new R[bar.size()]);
>>
>>68003475
>What do you code for?
I don't know what I want to do yet, which is why I'm not sure if I should stick with Python or get my feet wet in other languages.
>>
>>68002016
http://relm.ml/relm-intro
>>
http://comcom.csail.mit.edu/comcom/#Synquid
>>
>>68003268
Rust is a fine language. Stop giving a shit about SJW shit and just code.
>>
>>68003619
>.ml
>not ml related
>>
>>68003618
if you're at the whiteboard still, it doesn't matter what language you want to use yet, you need to fucking design the bounding boxes for your project
then you'll be able to assess if python is good enough for it and if there are specific languages that would make it easier or that are designed specifically for the job

alternatively, choose a language and roll http://better-dpt-roll.github.io/
>>
>>68003369
Be Enterprise Ready™, do AJAX, use namespaces.
>>
>>68003636
>code
Soiboy detected. And yes I do program, just not in a soi-lang that makes you brain dead.
>>
>>68003263
I use it mostly for semantically marking up technical documentation, like DocBook, DITA, or S1000D, which is also what I'm working on programming-wise atm:
https://gitlab.com/kibukj/s1kd-tools
>>
>>68003458

The syntax is simple to understand, but thats not the same as easy to read, or good as a data medium.

"Put ten exclamation marks between every letter" is a simple data syntax rule. But its horrible.
>>
>>68003613
java doesn't let you use:
new R[list.size()];

You can only instantiate R[] via { . . . } or calling another method. I can't find a method that works and don't know how to do { . . . } if I don't know what size the array has to be.
>>68003551
So yes, it is a meme language. But I have to use it for this project.
>>
>>68003658
Alright, sticking to it.
>>
>>68003758
Pic related is really easy to read.
>>
>>68003792

Relatively speaking, its much easier to read

shipping: "$5.95"


than

<shipping>$5.95</shipping>


But the readability of XML isnt even the worst part about it.
>>
>>68003827
what's the worst part about it?
size?
>>
>>68003827
this is why you use SEXPRs instead of XML
'(shipping #e5.95)
>>
Nothing today.
Did some Haskell and Python few days back.
Tomorrow it's Java as I'm maybe about to get a job at some big enterprise company and I will have to use it.
So, I'm going backwards it seems.
>>
>>68003835

Size but also the flexibility of the data structure. XML and Json are both built around data being totally without specification or shape. Any object could have any field that can have any value.

The problem is data is _supposed_ to have specification. It shouldnt be totally freeform. The flexibility is actually a disadvantage, because data shouldnt be sent unless it meets a certain definition, and the recipient of the data is going to be assuming a certain definition too.
>>
File: 1419030245111.png (527 KB, 811x710)
527 KB
527 KB PNG
>O(n) to get the length of a string in C
>>
File: 1501133209796.png (840 KB, 1537x899)
840 KB
840 KB PNG
>>68003915
>his code relies on fizzbuzz and academia wank to seem efficient
It doesn't matter how your strings are encoded as long as you're consistent and have safeguards around the boundary conditions
>>
>>68003915
Never really a major issue because you need to know the size of the memory block anyway to avoid overflows.
>>
>>68003905
there are XML schemas and JSON schemas
i am not aware of data storing format that enforces correctness of data
>>
>>68003947
>data storing format that enforces correctness of data
any binary encoding, from images to protobuf
>>
>>68003993
>binary encoding
yeah, nah
>>
>>68003835
Ambiguity between content and attributes.
<foo bar="qux"/>

<foo>qux</foo>

Which of these should you use?
>>
>>68004065
that is the matter of choosing convention, not really problem of format
it's like choosing between CamelCase and camelCase
>>
>>68003942
sooo, just like a c++ string, except with a basically useless extra character
>>
>>68004065
Maybe a more enlightening example:
<foo bar="qux" corge="grault"/>

vs.
<foo>
<bar>qux</bar>
<corge>grault</corge>
</foo>

It may seem like it's obviously the first since it's shorter and thus cheaper to transmit (XML, after all, is an interchange format). However, you can only have one level of nesting with the first, whereas the second is unlimited.

Meanwhile, in JSON:
"foo": {
"bar": "qux",
"corge": "grault"
}

It's small AND it's nestable.

>>68004126
Why is it necessary to allow the choice in the first place? There are trade-offs, yes, and it's possible to make an optimal decision, but you're optimizing a problem that XML introduced in the first place and which many other markup languages do not have.
>>
>>68004176
Or maybe S-exprs.
(foo (bar qux) (corge grault))
>>
>>68004176
but it allows to be more verbose about data (vide >>68003905)
you can have for instance

<foo type="int">1234</foo>
>>
>>68004235
this, literally just an association list, simple and efficient
>>
>>68004065
"bar" presumably has some meaning, although I know where you're coming from because a lot of XML schemas will just have some throwaway name like "value" or "fooValue".

Maybe more like this:
<date year="2018" month="10" day="10"/>

<date>
<year>2018</year>
<month>10</month>
<day>10</day>
</date>


>>68004176
The usual reasoning is "elements for data, attributes for metadata", not that that's much clearer. I interpret that as something like:
<postalCode type="ZIP">91210</postalCode>

The data here is the postal code, @type is metadata on what kind of postal code system it's used in.
>>
>>68004176
json is easier to read for a human and easier to parse for a computer
as a static data exchange type it is far superior
xml provides some additional functionalities but they're not relevant for 90% of its usual usage
>>
lads i have to code conways game of life in parallel (MPI) using C++ by tomorrow.

gonna kms school only taught me baby tier java and C#
>>
>>68004160
C++ are null terminated as well.
>>
>>68003935
Are you retarded? It's just logic, traversing a 1024^3 length string to find the null value at the end isn't efficient. Python is literally faster than C:
s = '1'*1024**3
for _ in range(100):
print(len(s))

$ time python3 strlen.py
1073741824
[...]
1073741824

real 0m0.382s
user 0m0.084s
sys 0m0.298s

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

int main()
{
int i;
size_t GiB = 1024*1024*1024;
char *s = malloc(GiB + 1);
memset(s, '1', GiB);
s[GiB] = '\0';
for (i = 0; i < 100; i++)
printf("%lu\n", strlen(s));

}

$ time ./a.out
1073741824
[...]
1073741824

real 0m8.017s
user 0m7.718s
sys 0m0.292s

Just embarrassing.
>>68003942
But you don't, that's the point of C strings, that they're "safe" arrays and the null terminator is expected and utilized in common string operations.
>>
>>68001709
Lisp is the most powerful programming language.
>>
>>68004447
obviously talking about std::string, which isn't
>>
File: Glitch_Distortion.png (977 KB, 1200x749)
977 KB
977 KB PNG
Can someone with some regex skill help me out?

I currently have files named
LettersNumbers.format

What would be the proper gsub command to replace it to
LettersLetters2NumbersNumbers2.format
>>
>>68004497
>knows the exact size of the string
>uses strlen
>in a loop
>>
>>68001740
Liar
>>
>>68004632
>each iteration may change the string
>only thing you can do is recheck the length, because libc string functions return a pointer at best or nothing
>>
>>68004606
Lisp does not have and cannot have a powerful static type system
>>
>>68004737
https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node44.html
>>
>>68004761
I bet you just googled "common lisp type specifiers" and linked the first goddamn result. Did you even read what you just linked?
>>
>>68004616
something like
gsub("(^\\D+)(\\d+)","\1Letters2\2Numbers2",titlevariable)

you can use regexr to test out regex, I don't know if that actually works past the expression
>>
>>68004774
Lisp has a more powerful type system than any statically typed language.
>>
>>68004925
And also way more inconvenient. There's a limit to how much use you can get out of the power of a language when it goes out of its way to make it harder to maintain in the long run. There's a reason more people don't use it.
>>
  const fnArr = [
function() {
this.win = true;
},
function() {
this.lose = false;
},
];
const obj = {};

console.log(obj.win)


This is some Java Script. I'd like to know of a way to use constructor functions like these on a const obj. It'll work if I just use 'let' on obj, but I was wondering how to do so with const.
>>
how do you get a programming job without applying anywhere
>>
>>68005157
connections
>>
>>68005157
how do you get a programming job without applying everywhere
>>
File: 45.jpg (44 KB, 430x423)
44 KB
44 KB JPG
Is there a good place I can go to for feedback on code and help with improving things I'm working on? I have no references to judge the effectiveness of the solutions with which I come up with and I'm pretty sure that's causing me to develop bad habits. Stackoverflow?
>>
>>68005330
4chan.org /g/
>>
>>68005330
>>>/dpt
>>
File: shen.png (14 KB, 200x200)
14 KB
14 KB PNG
>>68004737
*blocks your path peacefully*
>>
File: screenshot.5.jpg (84 KB, 323x231)
84 KB
84 KB JPG
Anyone have any experience with using Twitter's API?

Capturing live tweets using the streaming method is deprecated. Is there a way to do it via "api.home_timeline"?
>>
>>68005361
>>68005370
I meant for more basic questions like "would it be better to use x, or y in this situation?" or "are there any issues with the way this code is structured? Stuff that from what I've seen, most of this thread would consider to be intuitive.
>>
>>68005403
Oh, in that case you could try >>>/g/dpt
>>
>>68005403
post them here
beginner questions would make this thread much better than idiots arguing about language design
>>
const fnArr = [
function() { this.win = true;},
function() { this.lose = false;}];
const obj = {};
obj = new fnArr[0]
console.log(obj.win)

So this results in an error on MDN. Again, does anyone know how to use constructor functions on a const object in Java Script?
>>
Not sure if this is the right place to ask but can anyone recommend lectures or books on fundamentals of how computers work?
This is what I got so far -
https://www.youtube.com/watch?v=AfQxyVuLeCs&list=PL9F74AFA03AA06A11
>>
>>68005416
>>68005431
Well, I was wondering how I could go about improving this.

#counts the number of words in a string
def wcount(a):
x = 0
for i in a:
if i == " ":
x = x + 1
return x+1

test = input("Enter your sentence: :")
print(wcount(test))


As it stands the main issue I see is that because it just counts whitespaces, it's very easy to break. But I'm not really sure how to go about creating something that counts words. Also wanted to know if there were any other issues that stand out.
>>
>>68005552
hardware, firmware, software? what aspect of computers?
>>
>>68005670
I guess mostly hardware and firmware.
>>
>>68005637
Not sure what language you're using there, but I presume that any language worth using has some sort of string manipulation available. You'll have to search your language's documentation, but you're looking for something like
print(test.split(' '))


You might even be able to one-line it. (Again, I don't know what language you're using, so YMMV.)

print (input("Enter your sentence: ").split(' '))
>>
I've begun working on a terminal frontend for Wordnet using python. I basically want to run something like 'define -d word' and have it spit out the definition or synonym list based on the flags. It's a bit tricky though, as I don't have much experience with Python other than writing a couple discord bots.
>>
>>68005747
build a dictionary of known keywords for commands
connect that key to a function that will do flag parsing
query dictionary.com api
violin
>>
>>68005769
Issue is that I need it to work offline so dictionary.com won't work
>>
>>68005810
Then go find a well formatted copy of the oxford dictionary (or whatever particular version you prefer) and query that instead.
>>
File: 1485805377231.jpg (14 KB, 222x230)
14 KB
14 KB JPG
>>68001709
I can't spell. could I stell program?
I allwas was convinst I wasint abele to becors of my liring disabelaty. I ushrly use spech-to-text sine my spelling so bad and spell chack is time consuming.
>>
>>68005955
you can name your variables/objects whatever you want, but you'll still need to be able to type well enough to use the functions/methods of a library
>>
>>68005955
IDEs can autocomplete function names from your program and also the standard libraries
you still need to be consistent in your variable/function names though, misspelled or not.
>>
>>68005825
What's wrong with Wordnet?
>>
File: 1518949975793.jpg (162 KB, 1920x1080)
162 KB
162 KB JPG
>anon, the new H-1B workers have arrived
>we need you to train them to replace you
>>
>>68005955
>can't
>wasint
illusion broken

>>68006051
i actually misread that as wordpress
You should be able to just do the same thing and query against wordnet. There's plenty of docs on how to look up synonyms etc
>>
>>68006076
If I pulled off a wordpress based terminal dictionary then I would officially be a NEET
>>
>>68006088
pretty sure you'd immediately be hired by wordpress
>>
>>68005371
God's programming language.
>>
>be me
>working in webdev for 50-60k a year in NYC
>looking for new job
>give in and take triplebyte test I see everywhere
>passed
>have google hangouts interview
Any anon take it? Supposedly, they get even junior developers 120k yearly
What can I expect, except for what's in the guide
>>
File: Nene.png (495 KB, 668x719)
495 KB
495 KB PNG
>>68005728
Wow, this completely trivialized it. I feel pretty dumb with the way I was going about it.
>>
If you just call split() on a string with no arguments, it will work as a basic word splitter, so
len(my_string.split())
will count the number of splits. This will only split on whitespace characters, not punctuation or symbols, and you'll get blank or non-word strings to, so it's extremely dumb and not recommended.

If you want to make it a bit smarter, in the regular expression module using a simple r'\w+' regex will match consecutive sequences of word characters (approximately equivalent to words), and the findall() function will find all non-overlapping instances matching a specific regex in a string. So the line
len(re.findall('\w+', my_string))
will find all 'words' (as defined above), which is probably as smart as you need.

If you want to go further than that, then the 3rd party nltk (natural language toolkit @ nltk.org) has a word_tokenize() function that will intelligently split a string into words in nearly any language correctly, even ones that don't use whitespace between words.
>>
>>68001740
> haskell
> employed

Pick one
>>
>>68006343
Meant to reply to >>68005637 and >>68006160 of course
>>
In C/C++, what is the most cache-friendly associate array I can construct where the keys are excel column letters. Ex. keys 'a' < 'bb' < 'bc' < 'ccc'. The goal is so dereferencing map['bb'] would bring in map['bc'], map['bd'] into the cache line.

I know std::unordered_map uses linked lists as buckets, so maybe the best solution is to first convert the column letter to the numerical equivalent then store in a vector? I.e. to store ('aa',55) I first convert 'aa' to 27 then store my pair as map[27] = 55. Of course when I want to dereference map['aa'] I'll need to convert to 27 again, imposing some additional operations for each dereference.

What do you guys think?
>>
>>68006024
>you still need to be consistent in your variable/function names
My spelling is inconstant. I can get a word right one day and wrong the next.
I try to wghte /lit/ as a hoboy but I can't look at my misspellings for long. I am familiar with vim.

>>68005990
I can type correctly but it's slow. I'm using Aspell for this post and I sometimes need to confirm a correction in a dictionary because the words look the same to me.
>>
>>68006385
hash tables arent ordered and binary trees arent cache friendly so just use an ordinary array unless you have tons of keys
>>
rust seems interesting and I feel like learning it but how do you write GUIs for it?
>>
>>68006385
A) Converting from a char to an int is free, the compiler already does that, a char is already an int from 0-255 (unsigned)
B) map['aa'] isn't valid, 'aa' is not a char, its two chars, so its a string, and strings are complex data structures (relatively speaking)
C) A, AB, ABC, etc in excel are just human- readable enumerables in sets of 26.
What you SHOULD do is create a fuckhuge table of enumerables (i.e, constant integers) that map A to 0 and AA to 27 and AAA to idk what, 54?
This, however, is only useful if you can convert the column input you want before trying to do a lookup. e.g. The continuity between the original excel column and the end result internal C enumerable is irrelevant, and only meant as a readability convenience.

Otherwise you're gunna have to do a lot of fucky checking that will absolutely destroy your cache optimization, unless you have thousands upon thousands of rows per column.
>>
>>68006575
Sob uncontrollably, like most systems level languages.
>>
>>68006584
http://relm.ml/relm-intro
>>
>>68006343
>>68006358
Alright, the re.findall() seems to work even better, though I'm not sure if I should use that or the 3rd party nltk you mentioned since it might be against the rules of http://better-dpt-roll.github.io/#18
In any case, I need to study it more, since I really have no clue how that module works.
>>
>>68006599
I reiterate my previous statement.
You can make GUIs in C++ with dozens of libraries, or in Go with similar numbers. It doesn't make them any less fucking horrible.

GUIs are perhaps one of the few things properly well suited to GC'd OOP languages. C# and Java GUIs are a breeze comparatively.
>>
>>68003268
Mad that you're losing, white boy?
>>
>>68006575
Give up and use Electron
And low level, compiled language is gonna have difficulty porting, or is Java
>>
>>68003298
Yeah, it would be more like
country.giveVisa(migrant)

And Onions.drink() is
me.drink(onions)

This is why people hate OOP. cause filthy pajeets make spaghetti code
>>
>>68006385
You should obviously be using RC notation in excel anyway ala https://youtu.be/0nbkaYsR94c , but any program would be using integer indexes behind the scenes regardless and just treating the letters as an odd base26 numbering system for display.
>>
>>68006608
What's so bad about that? It looks decent to me.
>>
>>68006761
Examples always look decent. Actual GUI implementations are an undying nightmare that you will never recover from.
>>
>>68006672
it wouldn't be either of those
>>
>>68006834
well?
>>
>>68004497
here's some trivia:
where are you getting that 1024^3 length string from
it can't possibly be that you might have to read it in from somewhere else anyways can it?
You're pulling contrived examples out of your ass, completely divorced from reality
>>
>>68006964
>where are you getting that 1024^3 length string from
From stdin? Or reading from file. Don't tell me you've never parsed logs before. Or pretty much any string can get to the size of a gigabyte. So pretty much all the time, actually

>Anon. Your code introduced a DoS exploit to our code base
>t-this is a contrived example
>you're fired!
>>
>>68001709
I'm working on a Java project for school. I have to write some class methods and unit tests.

I wish my school didnt use Java to teach CS.
>>
>>68007073
Content-Length
"buffer sizes"
"rejecting queries containing strings larger than the allowed buffer"
>Anon, you don't know a goddamn thing about string parsing, you've had your hand held by high level languages all your life
>t-this is stupid why should I ever have to know about different binary encodings when am I ever going to use something other than an array with known length?
>You're fired!
>>
>>68007073
>From stdin? Or reading from file.
So you already know the length then.
>>
File: keywords.png (52 KB, 989x668)
52 KB
52 KB PNG
i made a /pol/ keyword search tool. you can look up the historical usage of words use on the on the pol board at https://news.coffee/keywords . it's only been scraping for a week so historical depth is limited.
>>
>>68002895
GB emulator
>>
Flatpak haters BTFO
>>
>>68007273
but why not appimage?
>>
>>68007230
you should let us query with regex
or at least wildcards
>>
>>68005520
You cannot re-assign a const variable. You can change its properties though, but in this case, you are already 'constructing' the object on declaration
>>
>>68006157
I heard working at google is shit, so study up on that. It's prestigious though so if you have a good personal life, go for it
>>
>>68006761
He's just memeing, there are loads of decent gui libraries for most languages from C/C++ all the way up to Python
>>
>>68002833
tell whoever made those rhat computers weren't made for that shit and fuck off
or get so sick your cumpany ends up firing you, like I did
>>
>>68001740
But are you employed for using Haskell, or a Starbucks barista who happens to program on Haskell on the side?
>tfw learning Haskell
>tfw doing project Euler ony free time.
>>
>>68007230
The lack of 'jew' 'nigger' and so forth leads me to believe this is inaccurate
>>
>>68007318
Oh sorry. I meant I have an interview over google hangouts. Not an interview for google hangouts
Fuck if I ever work for google tho
>>
Hi I'm new to metaprogamming

How do I obtain a reference to a method my program makes if I don't know what the name of the method will be until runtime?
>>
File: 4NwafYJ.png (10 KB, 1094x157)
10 KB
10 KB PNG
>>68007374
the lack of? try searching it. the words at the bottom are the active words on the board that have the greatest recent deviation from their norm.
>>
>>68007407
hey
don't fucking show me up
with your
data science tools
you
you
guy
>>
>>68001733
zig huyel
>>
>>68003775
y tf r u casting it back to an array list if you return an array? the issue sounds more to do with you trying to force hack some shit through your main method.
>>
File: 1523476560274.png (138 KB, 457x645)
138 KB
138 KB PNG
I have a List<String>. I want to output the contents of it to a .txt/notepad file with each index in a new line.

What are some good ways to do this? Java btw
>>
>>68007565
while (<>)
>>
>>68007584
idk how to put it out to a notepad/txt yet, still first year
>>
>>68007255
how much harder is it than chip8?
>>
>>68007625
waaaaay harder

6 times more opcodes
more interrupts, more flags, really kooky way of handling what's drawn on a line, managing the sampling of sounds, etc
>>
>>68007565
You can either write the string then write the newline afterwards or use a BufferedWriter to make the line separators.
>>
>>68007682
I'm assuming bufferedwriter functions the same way as bufferedreader?
>>
>>68007692
https://docs.oracle.com/javase/10/docs/api/java/io/BufferedWriter.html
https://docs.oracle.com/javase/10/docs/api/java/io/BufferedReader.html
>>
>>68007706
I got this to work and stuff, but I have a problem, say my array is 20 lines, my output txt is going to be 21 lines. I want it to be 20 lines

any way I can do that?
>>
>>68007989
Iterate over n-1 elements then write the nth one without the separator
>>
I want a cute 2D girl to turn me into a cute 2D girl and violate my holes (with her fingers of course).
>>
>>68007989
>say my array is 20 lines, my output txt is going to be 21 lines. I want it to be 20 lines
This is a bad idea.
Files in general, not just lists, are supposed to have an empty line at the end. That's what most other software in the world will expect when it opens your file, and some programs even make a point of marking deviation from this standard as an error in the file data.
>>
>the absolute state of python "string" abominations
Adding a single 4-byte unicode character to a 1-byte character string causes the entire string to be reencoded and take up quadruple memory. My system started swapping after adding that single character
>>
>>68008187
What would you rather python do?
Add it without converting to wide chars and turning string indexing into an O(n) operation?
I'd rather the one-time conversion to wide chars and retain O(1) indexing.
Not defending python of course. It's a shit programming language but not for the reasons you're complaining about.
>>
>>68007280
Not mutually exclusive
>>
>>68008215
Indexing could still be O(1) by storing pointers to arrays with a header that defines word size. Then cast/memcpy or however to word size from the header offset and you have your character. Does this use more or less memory?
>>
>>68008280
Sounds fucking horrible.
>>
>>68008280
Dont know what the fuck you're talking about but there's no way to efficiently index a variable char width string
>>
>>68008280
And yes, it'd probably use up to 4x more memory.
>>
File: 1538650046571.png (145 KB, 392x470)
145 KB
145 KB PNG
int main(string[] args) {
import gio.Application : GioApp = Application;
import gtk.Application : Application;
import gtkc.giotypes : GApplicationFlags;

auto app = new Application("org.gitlab.radagast.gtkdnotes.spinsbutton",
GApplicationFlags.FLAGS_NONE);
app.addOnActivate(delegate void(GioApp _) {
import gtk.ApplicationWindow : ApplicationWindow;

auto aw = new ApplicationWindow(app);
scope (success)
aw.showAll();

aw.setTitlebar(() {
import gtk.HeaderBar : HeaderBar;

auto hb = new HeaderBar();
hb.setTitle("SpinButton Demo");
hb.setShowCloseButton(true);
return hb;
}());

aw.add(() {
import gtk.Box : Box;
import gtkc.gtktypes : GtkOrientation;

auto hbox = new Box(GtkOrientation.HORIZONTAL, 10);

import gtk.SpinButton : SpinButton;

auto spinButton = new SpinButton(0, 100, 1);
hbox.packStart(spinButton, true, true, 0);

import gtk.CheckButton : CheckButton;
import gtk.ToggleButton : ToggleButton;

auto numericCheck = new CheckButton("Set numeric");
numericCheck.setActive(true);
numericCheck.addOnToggled(delegate void(ToggleButton _) {
spinButton.setNumeric(numericCheck.getActive());
});
hbox.packStart(numericCheck, true, true, 0);

auto validityCheck = new CheckButton("Valid only");
validityCheck.addOnToggled(delegate void(ToggleButton _) {
import gtkc.gtktypes : SpinButtonUpdatePolicy;

spinButton.setUpdatePolicy(validityCheck.getActive()
? SpinButtonUpdatePolicy.IF_VALID : SpinButtonUpdatePolicy.ALWAYS);
});
hbox.packStart(validityCheck, true, true, 0);

return hbox;
}());
});
return app.run(args);
}
>>
File: 1525740823023.png (536 KB, 814x734)
536 KB
536 KB PNG
>>68004732
>mutating
>>
why are most programmers so conceited?
>>
>>68008321
Akarin is cute
D is dead
>>
>>68008608
Why are most humans so conceited?
>>
>>68008627
What a conceited statement.
>>
>>68008635
I prefer expressions.
>>
>>68008300
But it would maintain constant string size instead of quadrupling randomly while allowing O(n) indexing.
>>68008305
>but there's no way to efficiently index a variable char width string
Here's a proof-of-concept that allows O(n) indexing while storing variable-size characters, at the cost of a 1-byte header per character:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void wordprint(char **words, int cnt)
{
int i, j;
char wsize;
for (i = 0; i < cnt; i++) {
wsize = words[i][0];
for (j = 1; j <= wsize; j++)
putchar(words[i][j]);
printf("\tis a %d-byte character\n", wsize);
}
}

int main(int argc, char **argv)
{
if (argc < 2) return 1;
int i;
char wsize;
char **words = malloc(sizeof(*words) * (argc-1));
/* store characters from argv*/
for (i = 1; i < argc; i++) {
if ((wsize = strlen(argv[i])) > 4) return -1;
words[i-1] = malloc(wsize + 1);
strncpy(words[i-1] + 1, argv[i], wsize);
words[i-1][0] = wsize;
}
wordprint(words, argc - 1);

return 0;
}

Not sure about how you'd go about efficiently decoding, though.
>>
>>68009017
>O(n)
O(1), I meant
>>
Does data oriented design offer any benefits to c++?
>>
>>68009082
To C++? What an odd question. If you're talking about projects written in C++ then yes. You can't just write whatever in C++ and have it be fast by default. How you write it is more important than say in managed languages. C and C++ are about control, not speed.
Data oriented design is by definition the way of doing fast transformations (since it only calls for you to consider the ways of doing fast transformations with regards to hardware). Right now that's usually concerning yourself with how you store and access your data because memory is relatively slow. It'll help in any language where you can express contiguous memory well.
>>
>>68007230
>>68007407
you can probably populate your historical usage with archives
In that case, you can also make a statistic attack on deleted posts word usage
>>
I'm trying to understand iterators (btw my only experience with c++ is reading /dpt/ code snippets & autistic banter)

so this gave me an error
vector<int> vec(2);
auto it = vec.begin();
foo = (char *) it; // can't cast iterator to char *

but
 foo = (char *) &(*it); 
works perfectly, I wouldn't be confused if the second thing didn't work. Isn't it just a pointer?
Shouldn't &(*x) always be equal to x ? Like & is just the inverse of * ?
>>
>>68009519
it is an object, can't be cast into a pointer
* is an overloaded reference operator, which gives you the currently pointed object
*it is actually the content of the first element of your vector
&(*it) is the adress of this element, that is an int*, easy to cast into a char*
>>
>>68009608
>it is an object, can't be cast into a pointer
C++let out
>>
>>68009608
>overloaded reference operator
Wait wtf you can overload * and &
anyways, thx for the explanation
>>
Is this UB? How bad is it?
What's the alternative?

vector<int> vec {1,2,3};
o.write((char *) vec.data(), sizeof(int) * vec.size());

vector<int> tor (vec.size());
i.read((char *) tor.data(), sizeof(int) * tor.size());
>>
File: 1536461729788.jpg (34 KB, 560x560)
34 KB
34 KB JPG
Hmm, I wonder why they haven't made a virtual method for switch handling in GtkD

void main(string[] args) {
import gtk.Main : Main;
import gtk.MainWindow : MainWindow;

Main.init(args);
scope (success)
Main.run();

auto mw = new MainWindow("Switch Demo");
scope (success)
mw.showAll();

mw.add(() {
import gtk.Box : Box;
import gtkc.gtktypes : GtkOrientation;

auto vbox = new Box(GtkOrientation.VERTICAL, 5);
vbox.setBorderWidth(40);

import gtk.Switch : Switch;
import gobject.ParamSpec : ParamSpec;
import gobject.ObjectG : ObjectG;

/**
WARNING: HIGHLY questionable code, needs fixup.
*/
auto sw = new Switch();
sw.addOnNotify(delegate void(ParamSpec p, ObjectG _y) {
if (p.getName() == "active") {
static bool on;
on = sw.getActive();

//do stuf
import std.stdio : writeln;

writeln(on ? "On" : "Off");
}
});

vbox.packStart(sw, true, true, 0);
return vbox;
}());
}
>>
>>68009642
>overloaded reference operator
sorry, meant dereference
and yeah you can overload most operators in c++
https://en.cppreference.com/w/cpp/language/operators

>>68009642
?
>>
>>68009947
was meant for >>68009665
>>
what's the deal with calloc?
why doesn't it take just size like malloc?
>>
>>68009947
>?
https://en.cppreference.com/w/cpp/language/cast_operator
Objects certainly can be casted to char* provided they have the right conversion operator defined.
>>
>>68001709
I did a game of life just for fun.

What are other 'fun' projects? I've spent too long as a web developer and its starting to make me hate programming lmao
>>
File: game-of-line.gif (531 KB, 595x600)
531 KB
531 KB GIF
>>68010064
forgot pic
>>
>>68010054
trying to keep it synthetic for whom is obviously a beginner, but thanks for this impressive display of knowledge
>>
File: 1536139489132.jpg (14 KB, 236x305)
14 KB
14 KB JPG
>github avatar is le 30 year old boomer pic
>>
>>68010078
>dumbing down things for dummies
Just recommend them Python or something.
C++ isn't for brainlets.
>>
>>68010097
yes, because adding irrelevant (and dangerous) language features into the mix when teaching beginners is an excellent teaching method
pretty sure you're a C dev posing as a c++ dev to make us look bad
>>
>>68010149
I realise this was a tad harsher that I would have wished, sorry about that
>>
>>68010149
>"irrelevant"
>"dangerous"
Yeah just go back to Python.
I don't think programming is for you.
>>
File: 1481258440460.gif (135 KB, 434x400)
135 KB
135 KB GIF
>>68010091
>pull request
>contributor has anime profile pic
Thank you for you contribution!
>>
>>68010214
you sound like an undergrad student who had his first class about operator overloading and now can't get over himself
maybe when you're a bit more experienced you'll understand the value of what I told you
>>
>>68010257
>Hur dur muh assumptions
Back to Python with you.
Features are only dangerous if you're retarded and retarded people shouldn't be touching computers.
>>
>>68010288
>>Hur dur muh assumptions
thanks for backing them up
>>
>>68001886
>over rust
lol nice try
>>
>>68010064
Virtual machine + bytecode compiler
Hardware-accelerated raytracer
PDE solver
>>
What's the easiest Python GUI framework available?
>>
QUICK!
iqm or <your own defined binary representation>
>>
>>68010507
try kivy or pyqt
>>
>>68010097
>Python
>>68010214
>Yeah just go back to Python.

python has operator overloading.

a + b is actually

try:
return a.__plus__(b)
except:
return b.__plus__(a)
>>
>>68010569
>

try:
return a.__plus__(b)
except:
return b.__plus__(a)

I don't believe it.
>>
>>68010507
https://python-gtk-3-tutorial.readthedocs.io/en/latest/index.html
>>
File: hYMIItH.png (142 KB, 511x564)
142 KB
142 KB PNG
>>68010590
https://ideone.com/zqyRUc
>>
File: please_eat_my_legumine.png (678 KB, 1416x2004)
678 KB
678 KB PNG
>>68010590
>>68010617
more about that here
https://docs.python.org/3/reference/datamodel.html#emulating-numeric-types
>>
/g/, I need your help

FILE *fp;
t_data dat;
fp=fopen("file.bin","r+b");
fread(&dat, sizeof(t_data),1,fp);
while(!feof(fp))
{
if(dat.aaaa==2018)
{
int pos = ftell(fp)-sizeof(t_data);
dat.prec=2;
fseek(fp,pos,SEEK_SET);
fwrite(&dat,sizeof(t_data),1,fp);
}
fread(&dat, sizeof(t_data),1,fp);
}
fclose(fp);


what the hell am I doing wrong?
>>
>>68010898
Do proper error handling and your computer will tell you what you're doing wrong.
>>
Have an interview with Adobe in a couple of days. Instead of studying hard problems I just spent five minutes or so browsing /g/ and coming up with this fizzbuzz solution.
>>
>>68009760
It should be well defined provided your implementation does not have any trap representations for int (presume it doesn't)
>>
>>68010933
I think that I did it...
it doesn't modify the file and never get the feof
>>
>>68010937
That's cute, but you could get rid of the if() clause by having a 4-item array with "%d\n" in the first one (and adding \n to the other strings and making it start at 0 not -1) and passing the string directly to printf with your number.
>>
>>68011000
It's been a long time since I've used C file operations, but doesn't the '+' mean you can only append to the end of the file? So if that's the case, you're setting the fpos() back inside the if clause, but the write's failing so the file pointer never gets forwarded back to the end of the data, so you get an infinite loop of reading the same data over and over again.
But if you were checking your return values, it would tell you all about that.
>>
File: 1539114382370.gif (268 KB, 540x674)
268 KB
268 KB GIF
>>68001709
how would you alphabetically sort a string held in each different node of a linked list?
>>
>>68011113
store it in trie YOU FOOL
>>
what the fuck are you even trying to say?
>>
If f is some monotonic function, and f = O(n), why does that mean that there is some constant c such that
f(n) <= cn?

What is f in this case? The algorithm itself??
>>
>>68007230
What database did you use for this? Have been brewing something similar, nice to see someone else working on it too!!
>>
>>68005376
Wait what? I just made a project ~1 month ago that uses the streaming API.
>>
>>68002016
>>68002093
You never really stop learning Rust. It's a constant struggle between you and the borrow-checker. Eventually you get better at figuring out how to work within its constraints, but there will always be unforseen issues.

Really, it's a a good thing, though. Because almost every error occurs during compilation, the number of panics you get at runtime is drastically reduced. I've been using Rust for like a year and I can probably count the number of panics I've had (that I haven't explicity intended to trigger on some condition) on one hand.
>>
I know it's stupid, am I the only one here who's excited for Advent of Code 2018?
>>
>>68002093
I have stockholm syndrome with Rust's syntax. It's beautiful to me now because everything is explicitly stated.
>>
>Rust removes exceptions
>Introduces panics instead
Lol
>>
>>68002895
as an alternative to a GB emulator, make your own abstract virtual machine. Architect it however you want. You can make it really simple
>>
>>68011100
i am checking that, thank you!
>>
>>68011023
Oh fuck it actually worked.
I had no idea you could just pass in arguments to printf you aren't using!
>>
>>68011242
For Big-O notation, you say, "If I have an O(n) function, then it's of the form f(x) = c_1 * x + c_2". In this case, f(x) is how many steps your algorithm needs to run as a function of the input (and because it's Big-O, you take the worst possible case)
You can always choose some constant, k, where for large values of x, k*x > c_1 *x + c_2
>>
>>68011418
>doesn't know how printf is implemented
you fucking tool, go back to python
>>
>>68011418
You might want to read about how variadic functions in C actually work.

It's pretty ugly though.
>>
>>68011464
So like this SO post? https://stackoverflow.com/a/3579752
> If the format is exhausted while arguments remain, the excess arguments are evaluated (as always) but are otherwise ignored. The fprintf function returns when the end of the format string is encountered.

>>68011454
>I know everything
Yes yes, you're very smart. Shut up.
>>
What's the best language to write manly, non-gay code?
>>
>>68011491
Rust
>>
>>68011491
javascript
>>
>>68011491
C
>>
File: idiot_subject.jpg (98 KB, 996x720)
98 KB
98 KB JPG
>>68010937
>>68011023
rate my fizzbuzz
const int limit = 100;
int i = 1, count = 1;
while (i <= limit)
{
switch (count++)
{
case 3:
case 6:
case 9:
case 12:
Console.Write("Fizz ", i++);
break;
case 5:
case 10:
Console.Write("Buzz ", i++);
break;
case 15:
Console.Write("FizzBuzz ", i++);
count = 1;
break;
default:
Console.Write("{0} ", i++);
break;
}
}
>>
>>68011560
>Console.Write("{0} "
stop using vagina symbols in your code you shitlord
>>
>>68011576
i did it so i can put i++ inside.
>>
>>68011560
Instead of hard-coding the numbers, you can also do the 2-bit encoding I used in my implementation:

switch( (count%3) == 0 + ((count%5) == 0) << 1)
{
case 0: // not divisible by 3 or 5
Console.write("{0}", i++);
break;
case 1 // Divisible by 3, but not 5
Console.write("Fizz", i++);
break;
// etc..
}
>>
>>68011608
but it used modulo, anon
i don't like modulo.
>>
>>68011587
>i
stop taking all the credit from your code you shitlord, it's WE THE PROGRAMMERS you fucking cis male scum!
>>
>>68011621
do you dye your hair purple?
>>
isn't it faster for fizzbuzz to traverse two closed loop trees instead of performing modulo?
a size 3 close loop and a size 5 closed loop, the last entry in the list has "Fizz" for the 3 and "Buzz" for the 5, the rest is null character, each time the iterator is increased, traverse the lists, concatenate, and drop the iterator in the string if the string is null
How much slower is this solution?
>>
File: checklist.png (12 KB, 354x248)
12 KB
12 KB PNG
def fizz_buzz(n):                                                            
return (n%3 == 0 and "Fizz" or "") + (n%5 == 0 and "Buzz" or "") or n
for i in range(1, 100):
print(fizz_buzz(i))
>>
What's wrong with load time relocation? Isn't it better than position independent code?
>>
File: aho.png (38 KB, 1360x728)
38 KB
38 KB PNG
>>68011794
rate this one, senpai
no modulo
>>
>>68011794
Don't forget that to print a number printf() has to call % 10 and / 10 for each digit. Better to just iterate over the ASCII characters directly in a closed loop of length 10.
>>
>>68011828
in perl this is just
say "Fizz"x!($_%3) . "Buzz"x!($_%5) || $_ for (1..100);
>>
http://thedailywtf.com/articles/The-Fizz-Buzz-from-Outer-Space
LMFAO
>>
>>68011965
>3.14/3 == 5.14 fizz.
big, if true
>>
>>68012102
That's the biggest part.
I don't understand a single math in that article.
Alien math.
>>
>>68011828
Everybody can do it with modulus operator, can you do it without?
>>
>>68012175
def my_mod(n, m):
return n - (int(n/m)*m)
>>
>>68010227
where do i find repos where my contributions will be accepted just for using an anime profile pic
should we make an anime code of conduct
>>
>>68011954
In Haskell this is just
main = forM_ [1..100] $ putStrLn . \x -> let str = (if x `mod` 3 == 0 then "Fizz" else "") ++ if x `mod` 5 == 0 then "Buzz" else "" in if null str then show x else str
>>
>>68010227
RIP ;_;
>>
>>68001709
wearable lisp machine
>>
>>68003298
based and redpilled

USA.letin(m);

USA is singleton
>>
>>68012175
see >>68011560 and >>68011863
>>
>>68004235
reminds me of how some c++ fags got the idea to encode code as data into XML, except XML blows in comparison to sexps
>>
collecting code snippets from /dpt/ threads to produce a highly optimized general purpose library
BSD license of course
>>
>>68004606
Lisp isn't a language. It is a metalanguage to construct languages. I guess CL can be somewhat considered a language.
>>
Thinking of auto-meshing something by performing the loop-meshing algorithm.

https://www.cs.ubc.ca/~gberseth/blog/mesh-subdivision-with-the-loop-algorithm.html

For this, I'd need to get a list of the neighboring triangles/vertices for a single vertex. How would I do that? Would I need some structure along the lines of:

struct vertex{
Point3 location;
struct vertex[6] neighbors; //Maybe a heap would be good?
}

My only issue is that, given 1000 or so vertices, how would I find the six nearest neighbors for each one? Is there some reading I could do on this topic's implementation?
>>
rolled fizzbuzz. am i missing something, or is it supposed to be this simple? written in ruby.

(1..100).each do |n|
if n % 3 == 0 && n % 5 == 0
puts 'Fizz Buzz'
elsif n % 3 == 0
puts 'Fizz'
elsif n % 5 == 0
puts 'Buzz'
else
puts n
end
end
>>
>>68012313
>>68012239
It can take less operations and work without fucking modulo at all, are you all retarded?
>>
>>68006130
Uh...no. HolyC is
>>
>>68012354
You're comparing for n % 3 twice.

You've basically failed fizzbuzz.
>>
import itertools

def FizzBuzz(tl):
fb = itertools.cycle([None,None,'Fizz',None,'Buzz','Fizz',None,None,'Fizz','Buzz',None,'Fizz',None,None,'FizzBuzz'])
tlc=1
for fbstr in fb:
if tlc > tl: break
if fbstr: print (fbstr)
else: print(str(tlc))
tlc += 1
>>
File: idiot_too.jpg (220 KB, 1920x1080)
220 KB
220 KB JPG
>>68012362
i only know ++, senpai
>>
>>68004737
https://en.wikipedia.org/wiki/Racket_features#Typed_Racket
>>
>>68007230
>https://news.coffee/keywords
what did you write it in?
>>
New thread:
>>68012390
>>68012390
>>68012390
>>
new thread when? :3
>>
>>68007374
thats the first thing I searched, kek
>>
>>68012373
i dont understand how that fails. first condition checks for whether both conditions are met and prints fizz buzz, second condition checks exclusively for fizz, third condition checks exclusively for buzz.
>>
>>68008608
high iq does that to people
>>
>>68012421
not him, but i think it should be like this
if n % 3 == 0 && n % 5 == 0
change into
if n % 15 == 0
only 1 modulo in that line instead of 2 like yours
>>
>>68012335
If lisp can construct any language, why can't it construct languages without the need for parenthesis around fucking everything?
>>
>>68012467
ah gotcha. thanks.
>>
File: 1507484846491.jpg (26 KB, 645x729)
26 KB
26 KB JPG
>using division for fizzbuzz more than necessary
function* fizzBuzz(start = 1, limit = 100) {
let i3 = start % 3;
let i5 = start % 5;
while (start <= limit) {
let result = "";
if (!i3) result += "Fizz";
if (!i5) result += "Buzz";
yield result.length ? result : String(start);
++start;
if (++i3 === 3) i3 = 0;
if (++i5 === 5) i5 = 0;
}
}
>>
>>68012521
>generator with a finish parameter





Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

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.