[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 332
Thread images: 26

File: daily programming thread2.webm (2MB, 600x338px) Image search: [Google]
daily programming thread2.webm
2MB, 600x338px
old thread: >>55990669

What are you working on, /g/?
>>
First for Guile
>>
>>55996728
xth for statically typed languages
>>
>>55996728
OpenDNS API integration

Yay CRUD
>>
>>55996759
Static typing is obsolete, now that we have the processing power to make dynamic typing performant.
>>
>>55996798
Dynamic typing causes runtime errors and unexpected results.

Compile-time errors > runtime errors
>>
>>55996728
kill yourself
>>
File: 1470581816880.jpg (102KB, 722x638px) Image search: [Google]
1470581816880.jpg
102KB, 722x638px
In which situations would a *restrict pointer actually improve performance?
>>
>>55996825
Kill yourself.

>>55996798
Just look at the python anon from last thread.

He couldn't figure out why his function was returning void because dynamic weak typing was like "lol ok I'll just return None"
>>
>>55996809
Interactive development helps avoid such errors, which are in any case a small fraction of the total errors encountered during software development. The rapid development of software that is enabled by dynamic typing more than makes up for the small increase in runtime errors during the development process.
>>
>>55996842
>small increase in runtime errors
It's nice that you think that, but notice the bigger issue: unexpected results that are not errors.

The worst thing that can happen in a massive codebase is something not working quite right and no errors being thrown, particularly when working with critical data or money.
>>
wow i love c
>>
Fixed a memory issue in my music player. Now it uses 17mbyte instead of 460mbyte.

Wew
>>
>>55996889
What language, mummy?
>>
>>55996884
T D D
D D
D D T


I'm not in the dynamic typing crowd, but a correct algorithm will yield correct result regardless of whether it has been type-validated or not: it's correctly typed by definition.
>>
static typing seems bad only because of Java

When you have hindley milner inference, it's based

Even better when the langauge is expression based and type system is evolved past 1970
>>
>>55996889
what? you forgot to free something?
>>
>>55996884
Silent side effects can be just as devastating as (if not more so than) unexpected return values, and yet they are embraced by all mainstream statically typed languages. I think immutability and referential transparency are more important than static vs dynamic typing.
>>
>>55996920
>lol just write every function perfectly without anyone on your team ever making a mistake
Meanwhile, in the real world...
>>
>>55996931
C# master race

static by default
dynamic if I want it to be

managed code with GC by default
unsafe code if I want to use it
>>
>>55996938
I'm repeating myself, but
T D D
D D
D D T


Not sayin you should write perfect code at all. Try again.
>>
>>55996963
Tell me about how it can't implement functors
>>
>>55996920
What is that diagram?
>>
File: Tdd Ddt.png (79KB, 658x271px) Image search: [Google]
Tdd Ddt.png
79KB, 658x271px
>>55996965
What even is this alphabet soup bullshit

Tdd, is that you?
>>
>>55996965
Yes, have fun being a test monkey when you could eliminate 80% of your tests by using a proper type system
>>
>>55996974
What is the use-case for a "functor"?

I've genuinely never heard of them.
>>
>>55996965
>>55996920
>let me manually write all this testing boilerplate guaranteeing types when I could just use a sane language
>>
>>55996932

Lots of file handles.
>>
>>55997018
https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Functor.html

A use case is whenever you need one.

With it, you only need to implement fmap for a type and you get all the other functor methods for free.
>>
>>55997004
>>55997038
No mateys: Tests supercede and deprecate Typing, don't tell me you don't write tests? Typing doesn't excuse you from testing, but testing does excuse you from typing. Get this reasoning or is this too complicated for you munchkins?
>>
>>55997108
Sorry, I'm not going to pore over Hasklel documentation to determine what my own use-case would be.

If you'd like to give a real-world example, I'm all ears.
>>
>>55997018
"Functors" are informally things you can map over. Examples:
λ> import Data.Char
λ> -- apply function to all the elements of a list
λ> fmap ord ['a', 'b', 'c']
[97,98,99]
λ> -- apply function to all the outputs of a function
λ> let f x = replicate 3 x
λ> f 'b'
"bbb"
λ> let g = fmap (fmap ord) f
λ> g 'b'
[98,98,98]
λ> g 'w'
[119,119,119]
λ>


It's not that you can't implement functors in C#, it's that you can't implement Functor in C#. That is, you can't make a class or interface or whatever that captures a "Functor".
>>
>>55997121
No one said not to use tests, but adding a massive quantity of tests JUST for type verification when the language could do that part for you is a pain in the ass.

Dumb fucking faggot.
>>
SDL_Point* point = new SDL_Point(x+10, y+10);


Why does this give me an error? It says: "new initializer expression list treated as compound expression."
x and y are both ints.
>>
>>55997121
Of course you can write tests in statically-typed languages too. But you won't have to write the ones that are basically just typechecking, and it'll be better because you'll automatically have complete coverage for anything your types cover.
>>
>>55997148
prolly because the arguments of SDL_Point are not ints
>>
>>55997121
Found the college undergrad.
>>
>>55996728

Why would a language not concerned with memory management support type inference?
>>
>>55997177
Found the NEET
>>
>>55997186

*I mean why would they NOT support type inference
>>
>>55997175
They most certainly are.
https://wiki.libsdl.org/SDL_Point
>>
>>55996545
yeh
>>> rev = lambda s: ' '.join(s.split()[::-1])
>>> rev('poo in loo')
'loo in poo'
>>
>>55997205
Python lambdas are a joke, though.
>>
>>55997249
why?

you can't just go on the internet and say "Python lambdas are a joke, though."
>>
>>55997269
I just did.
>>
>>55997205
"poo in loo".ReverseWords();
>>
>>55997144
Types are straightforward and evident shit; if the type is wrong that means the value is wrong too, and by executing your test you'll catch that. Meanwhile, a wrong value of the right type can still typecheck, so you're still going to write the exact same tests (only with 10x more type bolierplate than code OLOLOLOLOLOL). I still think that proper testing can supercede type checking. I'm not arguing we should get right of typing because of that tho, it's just for the sake of the argument.
>>
i want some methods do things and return a boolean value indicating if they did it correctly, but also to store information in an object passed as an argument when it goes incorrectly. what's the name for this technique?

i mean to do it in python specifically
>>
>>55997277
so you have no arguments.

got it.
>>
>>55997269
It's probably just some schemer memer
>>
>>55997132
Much like everything else, it seems like more wankery.

Like you said, that series of functions is easily implemented in C#.

I'm not sure why anyone would care if it's called a 'Functor' or not.
>>
>>55997298
Python's scoping makes them almost useless.
>>
i'm working on a custom trie in c++.
i have it set up so each node has its own vector of nodes, which are its children

i want to be able to traverse the trie - but i'm not quite sure how i'd do that. does anyone have any suggestions?
>>
>>55997187
Honestly, you'll understand the benefits of dynamic typing the first time you work on a real project. When there are actual consequences to the correctness of your code, you learn not to trust yourself to do the compiler's job.
>>
>>55997328
provide some examples
>>
>>55997132
I'll leave >>55997324 to you, I'm not very good at explaining things.
>>
>>55997205
fn main() {
let rev = |s: &str| s.split_whitespace().rev().fold(String::new(), |r, a| r + " " + a);
println!("{}", rev("poo in loo"));
}
>>
>>55997340
>you'll understand the benefits of dynamic typing the first time you work on a real project.
so, you'll use python and not C++?

what are some dynamically typed languages?
>>
>>55997249
That's true, I don't like them myself but I still used a lambda instead of a regular function definition because I thought it fit the theme better but I absolutely agree that Python's lambda are garbage and pretty limited.

>>55997278
What language would that be?
>>
>>55997345
No, it's what's known as a non-constructive proof.
>>
>>55997358
stop posting. no one cares about your meme language
>>
>>55997340
>When there are actual consequences to the correctness of your code, you learn not to trust yourself to do the compiler's job.
This is an argument in favor of static, strong typing.

The compiler does LESS in a dynamically-typed language, forcing you to do more of the manual testing labor.

Unless of course you meant "not to trust the compiler to do your job".
>>
>>55997358
vomit/10
>>
>>55997368
>What language would that be?
C#
>>
>>55997369
>1+1 = 2
>prove it
>believe me bro!
>>
>>55997371
>>55997382

I love that simply posting Rust code triggers people
>>
>>55997376
>forcing you to do more of the manual testing labor.
No you don't. You do the same quantity as you should, but you get more from it. Meanwhile, you don't have to clutter your code with self evident typing information, or the even more absurd "compiler, please infer this type for me" bs.
>>
>>55997416
How would you test something that does IO?
>>
File: 1430853197680.png (331KB, 474x432px) Image search: [Google]
1430853197680.png
331KB, 474x432px
>muh lambdas
>>
File: 1467148829726.jpg (41KB, 635x473px) Image search: [Google]
1467148829726.jpg
41KB, 635x473px
>>55997360
>>55997376
I meant to say static typing.

A static compiler would have caught this error before I posted it.
>>
>>55997429
Fucking hell, anon.

You've gone and derailed the argument because your typos was THAT bad.
>>
>>55997416
>or the even more absurd "compiler, please infer this type for me" bs
Now you're just fucking trolling.
>>
>>55997429
https://m.youtube.com/watch?v=_hnc5PqipYs
>>
File: 1.png (148KB, 847x464px) Image search: [Google]
1.png
148KB, 847x464px
https://www.youtube.com/watch?v=ame2PH67gnk
>>
>>55997389
Seems like you missed the main & imports then, no? Both Haskell and Python solutions will work unto itself with no further additions.
>>
Can Python curry functions?
>>
>>55997492
maybe, but I know that Python and curry go hand-in-hand in India
>>
>>55997492
yes.
def f(a):
def g(b):
def h(c):
def i(d):
def j(e):
print(a, b, c, d, e)
return j
return i
return h
return g

print f(1)(2)(3)(4)(5)
>>
>>55997324
There are two reasons I can think of right now why you would want to make "Functor" a tangible thing in your language. As >>55997108
said, you don't have to reimplement functor-related shit for each type.

A related usage is when Functors are taken as input, not just simply existing. Admittedly, the only example I can take off the top of my head are Lenses (mainly used in Scala or Haskell), which are themselves sometimes called wankery. Without going into their details, a Lens is represented as a function, that must be able to have inputs and outputs that range over all Functors. Here is the type signature of a Lens:
type Lens s t a b = forall f. Functor f => (a -> f b) -> (s -> f t)

Here, this type signature needs to hold for every possible f that is a Functor. You can't even write this signature without having Functor be something you can range over (like a class or interface, or in Haskell, type classes). Lenses were originally made for updates and reads of parts of data structures. By switching out the f, you can implement a different operation with the same lens. The reason they don't simply use getters and setters is that you can compose different lenses together, and even compose lenses with things that aren't quite lenses, but are similar. This is enabled by the Lens (and friends) type being a synonym for functions, rather than a record containing a getter and a setter. I think this is out of scope of this post, since the usefulness of Lenses is not really established for my argument anyway, but I could go into it if you wanted me to. Or look through the variety of lens tutorials, since they would probably do a better job than me
>>
>>55997435
I started screaming IRL when I realized what I'd done.

>>55997504
kek
>>
>>55997512
No, I mean can you write a function in Python that takes an uncurried function as its argument, and returns a curried version of it?
>>
>>55997514
Forgot to add, the "don't reimplement stuff" argument is much stronger with abstractions with more structure, such as Applicative and Monad. These have more to work with, so you can implement more complicated functions that operate on them, and save more time than Functor by not having to reimplement. But Functor is a prerequisite for both those examples, so you could still say it's important.
>>
>>55997514
Fucking hell, anon, I asked for a real-world example.

Imagine you're a living, breathing, normal human, rather than the turbo-autist you seem to be.

While you've been quite informative in your own way, you're still just wanking.

Give me an example of an actual problem that this would solve in a codebase. How does it relate to a sample of existing data?
>>
>>55997515
>screaming IRL
Jesus anon it's just a thread
>>
>>55997512
Absolutely disgusting.
>>
>>55997529
You could probably do it with functools.partial but I'm not sure.
>>
>>55997541
I sometimes just close threads when I say something real stupid
I know we're all anon, but I still can't handle the embarrassment
>>
>>55997529
from functools import partial

def f(a, b, c, d):
print(a, b, c, d)

g = partial(partial(partial(f, 1), 2), 3)

g(4)
>>
>>55997425
How is that even something that seems like a candidate for being a good argument to you? Have you ever seen a testing framework in your life? And I'm gentle in that I'm not asking you to provide an example of an IO-related function that has a hidden type issue that isn't revealed at test-time...
>>
File: Bunny-hug.jpg (158KB, 500x667px) Image search: [Google]
Bunny-hug.jpg
158KB, 500x667px
>>55997561
Here, let this bunny give you a hug.
>>
>>55997575
Interesting, thanks. I wonder if there's any special machinery needed to make it immune to scoping issues.
>>
>>55997581
I've seen mocking, abstracting over services etc and they're unsatisfactory.
>>
Why in the fuck does Javascript refer to lists as arrays?

I just had a 30 minute argument with a front end dev pleb who was confused because of the terminology. Why has this not been changed yet?
>>
>>55997667
>ever arguing with frontend fags
why
>>
>>55997667
>lists
You mean vectors?
>>
>>55997701
It's a buddy of mine. I was talking to him about javascript lists over lunch (I assumed they were called lists because you don't have to set a length) and he got butthurt.
>>
>>55997655
How? I'd see more of a sample input file personally, but in either case HOW is that unsatisfactory? I don't care about that debate, but if you don't care to substantiate your claims you might as well shut up bro.
>>
>>55997715
Sure anon. Same thing really.
>>
>>55997667
>>55997717
But Arrays are lists, and linked lists are lists. but lists are an ABC for a mutable, in-memory sequence of references to objects. Is that right?
>>
>>55997291
pls help
>>
>>55997845
"Errors are values". Golang does it a lot, but contrary to it Python has exceptions you no?
>>
>>55997814
An array is a fixed-length sequence of allocated memory spaces. A list is simply a sequence of stored objects that may or may not use an array. Hence the name "ArrayList" in Java, and "List" in Python.
>>
>>55997875
I.agree(manner=new CompletelyFlag())
>>
>>55997205
"poo in loo".split.reverse.writeln;
>>
>>55997291
>>55997845
>>55997874

See also: https://en.wikipedia.org/wiki/Option_type
>>
>>55997540
I can try to give an example for lenses, I'm not too confident about it though. Maybe you have data structures representing account infos.
data VPS = VPS { _os :: String, _ram :: Int }
data Email = Email { _address :: String, _emails :: [String] }
data Acc = AVPS VPS
| AEmail Email

We can use some templates provided by the language to automatically get these lenses:
-- Selects the OS name of the vps
os :: Lens VPS VPS String String

-- Selects the ram amount of the vps
ram :: Lens VPS VPS Int Int

-- etc. etc.
address :: Lens Email Email String String
emails :: Lens Email Email [String] [String]

We also have this, which will select all the elements of a list
traversed :: Traversal [a] [a] a a

A traversal is like a lens, but selects multiple elements, and has a slightly different type definition:
type Traversal s t a b = Applicative f => (a -> f b) -> (s -> f t)

This lets you compose a lens with a traversal, and the result is a traversal.
You can also define (there might be macros for it, I don't remember) Traversals that
-- Select 1 VPS if the constructor is AVPS, otherwise select nothing
toVPS :: Traversal Acc Acc VPS VPS

-- Same for emails
toEmail :: Traversal Acc Acc Email Email

Lets say we have a database of accounts, represented by a list
type DB = [Acc]

Then we can make a traversal that selects all the emails (messages, not accounts)
allEmails :: Traversal DB DB String String
allEmails = traversed.toEmail.emails

The dot is a function composition operator. This basically says to select every account, then select only the ones that are email accounts, then select all the messages in each selected account. We can use it to, for example, get the total character count of all emails together
charCount :: DB -> Integer
charCount db = sum (toListOf (allEmails.to length) db)

(continued)
>>
Probably a dumb question, but what's the best east-coast US school to go to for a cheap bachelors degree?

I know Julia, C++, and Lua, but noone will ever return my calls unless I have a stinking degree.
>>
>>55997784
That's the joke.

>C++ introduced vector, an array that automatically expands to fit an arbitrary number of values. There’s also a standard list type, which is a doubly-linked list. But wait! C++11 introduced the initializer_list, which is actually an array.

>Lisp dialects are of course nothing but lists, but under the hood, these tend to be implemented as linked lists — which is no doubt why Lisp originally handled lists in terms of heads and tails (very easy to do with linked lists), rather than random access (very easy to do with contiguous arrays).

>Perl (5)’s sequence type is the array, though “type” is a little misleading here, because it’s really one of Perl’s handful of shapes of variables. Perl also has a distinct thing called a “list”, but it’s a transient context that only exists while evaluating an expression, and is not a type of value.

>Meanwhile, in Python, list is the fundamental sequence type, but it has similar properties to a C++ vector and (in CPython) is implemented with a C array. The standard library also offers the rarely-used array type, which packs numbers into C arrays to save space — a source of occasional confusion for new Python programmers coming from C, who think “array” is the thing they want. Oh, and there’s the built-in bytearray type, a mutable sequence of bytes, which is different from an array that stores bytes.

>JavaScript has an Array type, but it’s (semantically) built on top of the only data structure in JavaScript, which is a hash table with string (!) keys.

>PHP’s sole data structure is called array, but it’s really an ordered hash table with string (!) keys. It also has a thing called list, but it’s not a type, just quirky syntax for doing deconstructing assignment.

>Lua likewise has only a single data structure, but is more upfront in calling its structure a “table”; there’s nothing in the language called “array”, “vector”, or “list”.
>>
>>55997938
Depends on what state you're in on the east coast. The NY SUNY system is pretty baller, can't speak for any other states though.
>>
>>55997973
I actually live in New York. Please explain further
>>
>>55997951
That's confusing.

Are you telling me javascript's "arrays" are built on top of their hash tables which are built on top of actual arrays?
>>
>>55998017
Everything besides primitives is a hash table in Javascript.
>>
>>55997992
Depending on your financial aid situation, you can go to a community college for (near) free (depending on where you go and how far up the need tree you qualify - i went for absolutely free and had all of my years covered in terms of textbooks) and there's almost-perfect transfer of credits between schools in the SUNY system. I say "near-perfect" because they change every year or so and some classes don't transfer as equally as others/as they did in other years. When I went to college I got to simply transfer out of my community college to my university with all my credits intact; however, now the requirement has shifted to that you MUST graduate from the CC before you transfer up.

Schools in the SUNY system are also welcoming if you have a Bachelor's already but that doesn't apply to you, I guess. I hate to ask on 4chan of all places, but are you closer to the city or Long Island? Or are you in the body of the state?
>>
File: maurice.jpg (31KB, 600x600px) Image search: [Google]
maurice.jpg
31KB, 600x600px
Is it the case that lexicographically comparing two utf-8 encoded sequences of unicode characters byte by byte yields the same result as lexicographically comparing them character by character in all cases, /g/? I'm prétty sûre of that, bùt not 100%.
>>
In my never-ending quest to reduce disk I/O to bare minimum, I'm seriously considering just reading the whole image archive to memory and then decompressing data from there when needed, instead of multiple fseek()/fread() combos.

The archive is from an older game and it contains RLE-compressed 8-bit textures. The whole thing is about 34 megabytes in size. Uncompressed it's about 70 megabytes.

It's a tempting idea.

I guess I'll do it. We got gigabytes of memory these days.
>>
>>55997932
toListOf is a function that takes a traversal and a thing the traversal selects into, and returns a list of everything selected. "to length" evaluates to a "getter" (basically a lens that can only read, not write) that selects the length.

With just this use case, it could have been done easily without lenses, maybe sprinkling in some list concatMaps (maps a function over a list, then concats the results) somewhere in there. But you could also reuse the same traversal to set values.
-- Replace all emails with "memes"
replaceMeme :: DB -> DB
replaceMeme db = set allEmails "memes" db


To implement this individually without using lenses you would have had to replace concatMaps with maps and move the selectors around, making it a bit more messy and requiring more work. The problem would be the same in C# since you can't use the . syntax to select the members/methods of elements of a list of things, you would have to throw in maps (or whatever the equivalent in C# is).

Lenses also let you select substructures in a sort of OOP-ish way because the composition is in reverse order, but that's specific to haskell and not a general problem.

This turned into posts about why lenses are useful, but since lenses depend critically on Functor, it's also why about Functor is useful.
>>
>>55997205
$s = "poo in loo";
echo implode(' ', array_reverse(explode(' ', $s)));
>>
>tfw wrote up a working Json WebToken example in less than 20 minutes

I think I'm getting the hang of this stuff, anons.
>>
>>55998054
Upper Manhattan.

So do you think going to a community college would be best? Do jobs really care about exactly which one you go to, or would they be suffices with just a bootcamp or something. I just want companies to call me back.
>>
>>55997874
>>55997916
thanks, but i'm not sure that's what i'm looking for. this is an example of what i was thinking about:
bool strDelete ([in] string id ,
[in] string path,
[out] strError error );[\code]

but in python. i know it would be easier using custom exceptions but i can't
>>
>>55998163
your competence is more important, community college would be fine, but work on projects on the side (regardless of which college you go to) so you have a portfolio to show to the employer
>>
OOP IN LOO
>>
>>55998163
>Manhattan
Ech. I actually dunno the CC status in the city but we've got some pretty solid CCs here in the periphery area between Brooklyn/Queens and Long Island

>So do you think going to a community college would be best?
Entirely dependent on your financial situation. I personally think its the way to go because it's not only cheaper, but colleges respect it much more than just directly applying because if you flex hard there, they don't see any need to worry about accepting you. Professors at a CC are also much more likely to help you if you know your shit and actually want to go the mile to get a degree

>Do jobs really care about exactly which one you go to
Some bosses who involve themselves directly with the process like to hire from their alma mater, but unless you went to a meme school or a poorly-regarded school (I don't think any of the SUNY universities are held in poor regard but some of the SUNY CCs are), no, no one really cares at all. What matters is how you present yourself and your performance. Projects, too; extracurriculars don't stop mattering just because you have skills without a bachelor's.

>Bootcamp
The biggest meme to exist. Concentrated pajeetium is injected into your bloodstream every class. Bootcamp success stories come from the bootcamp shuffling you off to a company that invested in them or that they have pull with.
>>
File: forward.jpg (136KB, 1920x1080px) Image search: [Google]
forward.jpg
136KB, 1920x1080px
>>55998270
>but i can't
>>
I was in this previously, but i have encountered a new problem.
This function returns lists within tuples within lists and all matter of chaos, although i just want lists within lists so i can easily slice lists from it. What do i do to fix that?

Also, this is maybe my third time coding so i apologize in advance for the triviality of the question.

seq=[int(x) for x in input("Enter your sequence with spaces: ").split()]
def dif(L):
return [(j-i) for i, j in zip(L[:-1], L[1:])]
def rec(L):
if len(L)<=1:
return L[0]
elif len(L)>=2:
return (dif(L)),rec(dif(L))

print(seq)
print(rec(seq))
>>
>>55998270
Dynamic typing
def strDelete(id, path):
if whatever:
return False
else:
return strError;

not beautiful but whatever
>>
>>55998309
>obummer
>>
>>55998270
def delete(id, path):
if condition:
return (True, "OK")

return (False, "Fuck off".)

(error, status,) = delete(1, "/whatever")
>>
>>55998281
>>55998294

Thanks for the help guys! I've been trying to avoid college for years now, but I guess there's no way to avoid it.
>>
>>55998343
def delete(id, path):
return (True, "OK") if condition else (False, "Fuck off".)

(error, status,) = delete(1, "/whatever")
>>
>>55998373
This isn't a golfing contest though, I was merely suggesting that he could use a tuple to return the error code and the message.
>>
>>55998320
depends. Could just as well
return dif(L) +  rec(dif(L)

that's one level of nesting less I believe

...

...

And that should cut it, no? rec returns a list instead of a tuple of (list + tuple of (list + ...)) or what ever and that's ok? The best way to get yourself out of the mayem is to not get into it I guess.
>>
>>55998396
+ does not work, just gives TypeError: can only concatenate list (not "int") to list
The functions returns this, by the way, to be specific:
Enter your sequence with spaces: 1 8 27 64
[1, 8, 27, 64]
([7, 19, 37], ([12, 18], ([6], 6)))
>>
EXTENSION METHODS
>>
>>55998465
Then substitute
        return L[0]

for

        return [L[0]]
,
What's this algorithm anyway?
>>
>>55998472

Are really nice.
>>
>>55998494
Its intended to find the difference between neighbouring terms in a list, label this as a new list, then find the difference between neighbouring terms in this new list, all the way down until there is one term left. It will eventually be used in a pattern finding function i have derived.

I tried the substitution, but this gives one list instead of a list of lists. What i want to be returned is:
[[7,19,37],[12,18],[6]]
>>
>>55998562
def dif(L):
return [(j-i) for i, j in zip(L[:-1], L[1:])]
def rec(L):
if len(L)<=1:
return []
elif len(L)>=2:
return [dif(L)] + rec(dif(L))

ftfy
>>
>>55998642
I am retarded. I should have known that
Thanks for the help
>>
File: prolapsed anus.png (6KB, 473x79px) Image search: [Google]
prolapsed anus.png
6KB, 473x79px
>>55998510
I like to write extension methods for the object class, so I can call them on anything for any reason.

Just in case.
>>
>>55998472
Are a hack.
>>
>>55998510
Aren't they just syntactic sugar for static utility classes with the added bonus of a higher likelihood of namespace collisions?
>>
>>55998970
>Aren't they just syntactic sugar for static utility classes

Essentially.

>added bonus of a higher likelihood of namespace collisions?

If you're a moron, perhaps.
>>
>>55998017
What's the actual problem? If you are using javascript you aren't supposed to care about the underlying architecture. That's what a language like C or C++ is for.
Javascript performance is fine for what it does, even on mobile devices with weaker processors if used correctly.
>>
>>55998741
I tried to do that in Rust

trait Suck {
fn suck_my_dick(&self) {
println!("Suck my dick");
}
}

impl<T: ?Sized> Suck for T {}

struct Foo {
bar: char,
}

fn main() {
1.suck_my_dick();
[1, 2, 3].suck_my_dick();
(1..100).suck_my_dick();
"Poo".suck_my_dick();
Foo { bar: 'a'}.suck_my_dick();
}
>>
>>55999004
>If you're a moron, perhaps.
Or if you use two libraries that happen to have implemented the same utility method?

Why the emotional response?
>>
I am too lazy to continue muh latest project, but when I do continue it hours pass.

Will this be a problem lately?

Also when some college project comes up I finish my part very quickly, not at once of course but in a week cause I am scared shitless for some reason.

Other guys in my team are amazed by it but it feels somewhat heretic.

> inb4 spaghetti

I do make plans for the projects and it is done very quickly.
>>
What's wrong with Java?

I'm actually serious. Never used it so I couldn't know.
>>
>>55999139
>Why the emotional response?

I like C# and if I don't defend it, I don't get my $$Microbux$$.

>>55999096

The one thing I really like about Rust is that the definition of an object and its methods are distinct. Really nice.

>>>inb4 functional programming invented that
>>
>>55999184
There is no problem with your penis. 5 inch is the average. You only need to pay attention to the gurl and you both will have a perfect time.
>>
>>55997127
A functor is any higher order function that takes arbitrary functions and returns a function.

A typical example of one would be map. It takes any function of type a -> b and returns one of type [a] -> [b], which simply applies the function to each element.

Generally it is any function that satisfies fmap id = id and fmap f.g = (fmap f) . (fmap g)
where dot is composition.

You can implement functors in any language that has first-class functions. They are not unique to Haskell, don't be fooled into thinking that.

What Haskell does in particular is give you a powerful type system that allows you to have a single function fmap that is type overloaded so that it can express all possible functors you can come up with by just changing the type of its input. This allows you to write methods that work for any functor by just using fmap and letting type inference overload the function for you starting with the overloading of fmap.
>>
>>55998970
>the added bonus of a higher likelihood of namespace collisions
Even if this does happen, the worst thing you'd need to do is simply specify the namespace inline.
>>
Tryin to figure out what the window[] does, the package name is an Id selector

function price_crosscheck(package_name, cost_type) {
var total_value;
var total_value = (window[package_name])[cost_type];
parseInt(total_value);
return total_value;
}
>>
>>55999209
>A functor is any higher order function that takes arbitrary functions and returns a function.

not true

const (\x -> ...)

plus contravariant functors
(a -> b) -> (f b -> f a)
>>
File: var.png (4KB, 88x293px) Image search: [Google]
var.png
4KB, 88x293px
Fuck the police, var everywhere.
>>
>>55999244
Also I know total value is declared twice
>>
>>55999278
kys
>>
>>55999384
I don't want to kiss you
>>
>>55999400
var kys = KillYourSelf();
>>
what gcc version you guys using?

mine:
gcc version 5.4.0 20160609
>>
>>55999438
GHC 8.0.1

>>55999421
I'm telling you I don't want to kiss you
>>
>>55999438
gcc 6.1.1-5
>>
>>55999531
>GHC
lmfao kill yourself
>>
>>55996728
>What are you working on, /g/?
To make this...
>>
Should i bother reading "The C programming language"? It's quite short, but at the same time i feel like "The C++ programming language" covers everything relevant from C.
Did any of you guys gain any insight from reading h&r's C?
>>
>>55999702
Wow you made a text editor?
>>
File: VisualStudio.gif (63KB, 859x691px) Image search: [Google]
VisualStudio.gif
63KB, 859x691px
>>55999702
...look more like this.

>>55999704
Just do it.
>>
>>55999706
No, It's Visual Studio Code. Looks like some horrible mobile "app".

I'm not using a chinese portable botnode for coding. I'm sitting by my desktop computer.
>>
>>55999709
You're looking for MonoDevelop.

VS Code is a lightweight text editor with IDE features, not an IDE.
>>
Javascript embedded in SVG

https://upload.wikimedia.org/wikipedia/commons/b/ba/Toy_train_SMIL.svg
>>
What whould you suggest me for building
c++ apps with html+css gui?
>>
>>55999747
>VS Code is a lightweight text editor with IDE features
>lightweight text editor
>lightweight
>>
>>55999747
Thanks! But can't VS Code be customized to be a "real" IDE?

What I want is to have an IDE for COBOL without having to dick around with GnuCOBOL.
>>
>>55999816
Not quite html, but take a look at QtQuick and QML.
>>
>>55999867
>But can't VS Code be customized to be a "real" IDE?
yes! for just $29.99 a month!
>>
Should Indians be allowed computers?
>>
>>55999895
Should you be allowed computers?
>>
>>55999895
yes but not all
Something like driving test for computers
>>
>>55999878
>yes! for just $29.99 a month!
Oh! -_-
>>
>>55999907
Yes, because I poo in the loo.
>>
>>55999907
dothead spotted
helo my frnd
>>
>>55996728
This code's from a game called Else heart.break()

The game uses a scripting language called Sprak to control every object in the game world
Once you get an item called a Modifier you can alter how the objects in the game work, like creating a cup of coffee so strong it'll keep you up for days

The problem is certain objects, especially computers have functions that others don't, you can't make coffee that speeds up your perception of time, but you can make a cigarrette that does that

I wanted to network a bunch of computers in the game to a central point, and be able to call all the more useful functions from there, but I've hit a wall

Mainly the fact that a supercomputer you access late in the game has a function called GetPosition() that allows you to get the position of any character in the game automatically, I really want to keep this functionality but Hugin's cell is full of so many effects that my computer slows to a crawl whenever I load it

So the answer was to take the output of GetPosition() and send it to another system, You can do this pretty easily with
var person = Input("The person you're looking for ")
var target = Connect("CentralServer")
target.Print(GetPosition(person))


But I can't call GetPosition() remotely, I'll post the code I have in a moment
>>
>>56000007
Fuck me, so close
anyway
#TODO: Integrate Hugin's functionality with the rest of the network

ClearText()
Print("Chaos OS v0.5: Damn near Beta edition")

MainMenu()

void MainMenu()
Print("")
Print("Telehack")
Print("")
Print("Boot")
Print("")
string command = Input("Make Selection ")
if command == "Telehack"
Telehack()
else if command == "Boot"
Boot()
else
Print("FUCK YOU")
end
end


void Telehack()
var target = Connect(Input("Who is the target? "))
String remoteCommand = Input("Alright now for a command ")
if remoteCommand == "test"
target.Print("The connection is functioning")
else if remoteCommand == "Locate"
Print(GetConnections())
Sleep(3)
string person = Input("Who are you searching for? ")

#The following commands do not work
target.ReturnLocation(person)
else if remoteCommand == "Slurp"
#Slurp is super cool, it's a function allowing you to physically traverse between computers, basically a network based teleport
#This is in here so I can hop between CentralServer and Hugin to debug the connection
Slurp()
end
end

void Boot()
ClearText()
DisplayGraphics()
Print ("BootLoader")
Print ("==========")
Sleep (1)

if HasFloppy()
BootFromFloppy()
else
Print("Please insert floppy...")
end
end


#This is the code from Hugin
#I've stripped out a useless graphic, you input a character's name
#and the system spits out their current room cell & x,y co-ordinates within that cell


ClearText()

Print("")

var names = GetPeople()

loop
var name = Input("Enter name to look up: ")
Print(GetPosition(name))
end

#I wrote this, it's supposed to be called from the central server, arguements passed on and then a string containing the output sent back
#It works just great, but I can't call it from the remote machine

void ReturnLocation(person)
var target = Connect("CentralServer")
string location = GetPosition(person)
target.Print(location)
end
>>
>>55999909
And it should be derailing 50 threads about cuckoldry in /pol/ and /r9k/.
>>
>>55999187
>implying Rust isn't a functional programming language
>>
>>55997466
kek
>>
>>56000092
blame the mods for not doing their job
>>
Looking to become a lab assistant this year at school for one of the Java courses. I was thinking of applying to be a tutor instead, but I figured the lab assistant would probably be easier, especially since I'd be helping with a class that's learning the very basics of programming.

I could also take the opportunity to instill the seed of functional programming into them ehehehe...
>>
>>56000099
it isn't tho
>>
>>56000007
sounds like an entity component system?
>>
>>56000143
>instill the seed
into some puta faggot
>>
>>56000173
>into some puta
Si, como tu madre
>>
>>56000000
>>
>>56000172
I'm sorry but I don't know what that is

Bit of a noob at this whole programming thing
>>
>>56000191
wow, thats not nice
your filthy negro
>>
finished antichess AI

it's okay, just not very suited to play blitz, wrote it in python so takes 5-10 secs to go 6-7 levels deep per move, that's a lot

another problem with antichess is that static value function is a little annoying, in chess you can basically just do sum of piece values on the board and overpower the opponent, but in antichess you can lose even if you have much fewer pieces
>>
>>56000199
An entity is a "thing" that doesn't do anything on its own, except have an identity.
An entity can hold multiple components, which implement the entity's behavior. For example, you might insert a "Draw" component, which provides methods to draw the entity, and might internally store an image or something to draw. You could also insert (for example) a "Physics" component that keeps track of the entity's position and velocity, and lets you change them, etc.
>>
>>55996728
what's the issue here with SDL?

Why can't I compile a program with a window?

when using:
#include "SDL/SDL.h"
#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
//MessageBox(NULL, "Hi!", "...", MB_OK);
return 0;
}

int main( int argc, char* args[] ) {
//Start
SDL_Init( SDL_INIT_EVERYTHING );
//Quit
SDL_Quit();
return 0;
}

It compiles, but when trying:
#include "SDL/SDL.h"
#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
//MessageBox(NULL, "Hi!", "...", MB_OK);
return 0;
}

int main( int argc, char* args[] ) {
SDL_Window *window; // Declare a pointer

SDL_Init(SDL_INIT_VIDEO); // Initialize SDL2

// Create an application window with the following settings:
window = SDL_CreateWindow(
"An SDL2 window", // window title
SDL_WINDOWPOS_UNDEFINED, // initial x position
SDL_WINDOWPOS_UNDEFINED, // initial y position
640, // width, in pixels
480, // height, in pixels
SDL_WINDOW_OPENGL // flags - see below
);

// Check that the window was successfully created
if (window == NULL) {
// In the case that the window could not be made...
printf("Could not create window: %s\n", SDL_GetError());
return 1;
}

// The window is open: could enter program loop here (see SDL_PollEvent())

SDL_Delay(3000); // Pause execution for 3000 milliseconds, for example

// Close and destroy the window
SDL_DestroyWindow(window);

// Clean up
SDL_Quit();

}
>>
>>56000260
on the second one with trying to create a window, I get:

SDLTest.cpp|12|error: 'SDL_Window' was not declared in this scope|

SDLTest.cpp|12|error: 'window' was not declared in this scope|

SDLTest.cpp|19|error: 'SDL_WINDOWPOS_UNDEFINED' was not declared in this scope|

SDLTest.cpp|23|error: 'SDL_WINDOW_OPENGL' was not declared in this scope|

SDLTest.cpp|24|error: 'SDL_CreateWindow' was not declared in this scope|

SDLTest.cpp|38|error: 'SDL_DestroyWindow' was not declared in this scope|
>>
File: Dilbert-1990-11-05.gif (65KB, 1200x368px) Image search: [Google]
Dilbert-1990-11-05.gif
65KB, 1200x368px
>>56000137
Pajeet and Indra will do the job for the mods much more effecient.
>>
>>56000260
>two mains
uhh
>>
>>56000319
not both in same file/compiling
>>
File: Selection_011.png (280KB, 875x477px) Image search: [Google]
Selection_011.png
280KB, 875x477px
What is your opinion on C lion /g/?
>>
File: 1468111450538.png (1019KB, 900x900px) Image search: [Google]
1468111450538.png
1019KB, 900x900px
>when you try to optimize your GLSL code and something gets fucked but you can't find the mistake
>>
File: 1468274225076.png (150KB, 1024x713px) Image search: [Google]
1468274225076.png
150KB, 1024x713px
>>56000443
>subscription
>not free software
come on
it's 2016
>>
>>56000452
git gud you pleb
>>
>>56000443
>>55995785
i hear visual studio is pretty good
>>
>>56000477
>telemetry hidden in the core of VS
no thanks.
>>
>>56000470
it is free for students, all you need is to create account with your @edu email

>>56000477
visual studio is awesome, it is only good thing made by microsoft.
>>
>>56000500
>implying clion doesn't have telemetry/usage statistics
>>
>>56000515
you think you'll be a student forever? learn a more industry-standard tool that you won't have to pay for
>>
>>56000477
>>56000443
Srly, try Qt Creator you will be not disappointed.
>>
>>56000515
>for students
>all you have to do is give us your email
>all students get .edu emails
>>
>>56000515
>>56000541
https://www.youtube.com/watch?v=EUZEPa9GtIo

these tools make it very very attractive but I feel like it's something visual studio is going to get soon enough.

That automatic header including and header generation and such seem trivial to implement in visual studio and isnt worth a monthly subscription
>>
>>56000260
>>56000283
Shitty sdl installation.

Isn't is a hell of a lot easier to install libraries on linux?
>>
>>55996842
writing code in a dynamically typed language is only faster than poorly designed statically typed languages (unless your language is also weakly typed, but in that case you'll experience many more type errors that offset it)
>>55997121
>hand written tests that you come up with yourself are able to test EVERY POSSIBLE USE CASE
>software which is formally verified to test all cases can't match my testing
>>
>>56000541
Well, in my country most of firms use Clion, Intellij.
>>56000545
i tried it, but i month ago and i dont like it very much.
>>
>>56000608
>kazakhstan
also i doubt it
>>
>>56000470
>free as in free beer with a mickey
Ok.
>>
>>56000634
>Serbia
>>
>>56000568
>using namespace std;
>letting 16 year olds vote
>>
>>55997466
You can tell she didn't understand a word she said.
>>
File: doesntwork.jpg (40KB, 737x358px) Image search: [Google]
doesntwork.jpg
40KB, 737x358px
Can anybody help me out? I cant seem to make this one work.

It never stops getting input.
>>
what does it mean when the compiler throws:
Thread [2]: Suspended. error: illegal instruction
>>
>>56000736
click ctrl + D
>>
>>56000736
you've given it less than 80 chars of input
>>
>>56000452
whew, found it 20 minutes later. i forgot i baked a factor 2 in there to save a few multiplications
>>
>>56000770

But I used the or operator?

Shouldn't the loop quit if I enter a space?
>>
>>56000736
change || to &&
>>
Been working on a facial recognition app.
It's still a bit flaky, but opinions and bug reports welcome: https://www.raskie.com/#mememe

You can tell me about it here: https://www.raskie.com/#on-notice
>>
>>56000853
no, read it through
while arr[i] is not a new line

if arr[i] is a space
set arr[i] to a newline
i++
>>
>>56000853

Oh wait... forget about it.
>>
>>56000894
>facial recognition app.
what exactly does it do
in what way does it recognize faces
>>
>>56000853
>>56000905
so what happens is

arr[i] is a space
arr[i] is now a new line
++i
i is different now
arr[i] is no longer a new line
>>
>>55999438
same
>>
>>55996798
Static type information makes code inherently much more readable and self-documenting than anything in a dynamically-typed language.
>>
>>55999438
6.1.1 20160707
>>
>>55996931
Haskellcuck please be more subtle with your shilling
>>
>>56000990
damn you caught me
>>
>I use haskell, m'lady
*tips*
>>
>>55996931
>Haskell
>evolved passed 1970

still
no
pi
types
>>
>>55996833

Anywhere that would involve copying memory. That said, if you know your pointers won't alias each other, make them restrict pointers every time.
>>
File: 1445991425563.png (261KB, 569x563px) Image search: [Google]
1445991425563.png
261KB, 569x563px
How do libraries like opengl do same name functions with different parameters, in C?
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClearColor(0, 128, 128, 255);
>>
>>56000894

It uses a naive algorithm (most likely edge orientation matching) to compare your face an archived list of 100+ celebrities. Please give it a go. You can choose whether the image is stored or not.
>>
>>56001134
They don't
glClearColor takes a GLclampf (float)
the latter is cast to the former
>>
>>56001134
int example(const char* format, ...)
{
va_list ap;
va_start(ap, format);

....
return 0;
}

>>
>>55999278
It's Javascript?
>>
>>56001194
OCaml
>>
>>56001134
It's implicitly casting to float
>>
>>56000099

Why would it be a functional programming language?

Its type system looks a lot like typeclasses but it lets you violate functional purity all over the place with a single &mut keyword and you never have to think about monads.

Also it's explicitly-typed most of the time.
>>
>>55999187
>definition of an object and its methods are distinct
Isn't that just non-OOP
>>
a language easy to write in like python but fast like C

what is this languages name
>>
>>56001374
C++
>>
>>56001374
D
>>
>>56001374
Cython
>>
>>56001374
Befunge
>>
>>56001287
Ever since normies wanted to say they can do functional programming but realized they can't understand immutability or static types, functional programming has been redefined to mean using a language that has lambdas.
>>
>>56001528
those fucking normies xD
>>
>>56001385

Hahaha!
>>
>>56001535
????
>>
>retarded web-monkey wants to learn meme machine learning
>no math knowledge whatsoever
>completely lost already on the first week https://www.coursera.org/learn/machine-learning/home/week/1 (gradient descent, minimization, nerdy formulas)
>linear algerba review seems easy though

What to do anon? Learn pre-calculus, linear algrebra? Anything particular?
>>
>>56001374
Is python really that easy to write? How many times have you'll cowards even wrote legitimate python and not used external libraries. It's external libraries the language and if you don't learn the libraries thoroughly you'll just be writing magic. Most of those libraries are just FFIs from C and C++ anyways so Python is the answer(?).
>>
>>56001544
Hahaha!
>>
>>56001533
It's true, though. The term has been diluted so much as to be meaningless. Java is now considered a functional language, in addition to object-oriented. For many developers, 'functional style's means one way of writing JavaScript.
>>
>>56001557
you are fucking retarded if you think using a library in python is easier than using a library in some other language

or what, you never use libraries and write every single line of code you use
>>
>>56001593
>Java is now considered a functional language
by whom

ie sauce
>>
>every VHDL job wants years of experience

jdimsa
>>
>>56000853
>>56000869
>>56000905
>>56000919

Alright guys thanks, I see the programs mistake now.
>>
>>56001624
what did you except?

that they want some newbie working there?

nigga pls
>>
>>56001624
very high density lipoprotein?
>>
>>56000470
>>56000515
>>56000541
>>56000561

us.idea.lanyus.com

use http :// 114.215.133.70 : 41017 / as activation server, activates every jetbrains product i believe

They take those servers down from time to time since the based chinks host them, but they bring usually another up in like 2 days

>inb4 b8
>>
>>56001111
What does aliasing mean in terms of memory?
If I'm working with C strings and extracting substrings from larger strings, does that count as aliasing?
>>
>>56001821
forgot to add, i'd be making heavy use of pointer arithmetic to do it
>>
>>55999702
>>55999725
If you're going to use a meme editor, why not just use Atom?
>>
>>56001993
but i use Atom. I just wanted to be a bigger meme
>>
>>56001374
Typed Racket
>>
>>56002057
when using sdl, there is no console output, i slao do not see a stdout.txt file in working dir,

tried using
freopen("CON", "w", stdout); // redirects stdout
freopen("CON", "w", stderr); // redirects stderr

after SDL_Init, still no printed text on console, what gives?
>>
>>56001374
C
>>
>>56001601
What? All I said was that writing python is pure libraries so it's not that simple because you have to learn all these libraries.

I think you need to chill my man
>>
>>56001528

No, that's not it at all. It was actually the functionalfags who wanted to take credit for """inventing""" the features that these languages now have.
>>
>>56002175
i think i do sry kurt just overreacted a tad
its personal programming insecurities

here's a joke to make up for it

what's programming, that's when i fuck your mom whose name is 'prog', because im a nasty programmer

gedit?
>>
>>56002239
Ehh not sure if I'd borrow that one off you to tell the buds

and no I'm more of an Atom user myself
>>
File: brettygud.png (166KB, 299x323px) Image search: [Google]
brettygud.png
166KB, 299x323px
I'm a newfag. Same guy who was trying to make a text adventure yesterday. Gave up on that until I have a better idea of python (only language i can write).

Im still trying to find a good book to learn from, but in the mean time I figured out how to calculate factorials.

I know its something that probably everyone in this thread already understands, but when i figured out how

def factorial(n):
return 1 if n <= 1 else n * factorial(n-1)


Would expand to

factorial(7)
7 * factorial(7 - 1)
6 * factorial(6 -1)
......................


and understood why, it felt pretty awesome. I just want to learn more and more after figuring that out on my own.

As someone who just graduated high school a year ago, would it make sense to go into comp sci? I know recursion is pretty basic, but all of this stuff is so interesting to me.
>>
>>56002276
Text adventures are not really that rigorous because of how linear it ends up being, unless you plan on randomizing it
>>
>>56001821

Same memory address.
>>
>>56002276
I'd say go for it. A significant part of CS is indeed analyzing how complex algorithms become and finding better solutions to them.
>>
>>56002355
I figured out how to make a text adventure work, even with different scenarios for each area on the map depending on a coinflip, diceroll, etc, but the only way i know how to write it out is pretty verbose.

Each grid square on the map was its own unique function that had slight variations in structure, and then dialogue sequences used different functions to create a dialogue path. If you said 'yes', it opened up a function like dialoguexyz_yes, that had different dialogue options than dialoguexyz_no, and then after the dialogue was finished it would return to the xyzsquare() on the map.

I could write the whole thing out like that, but I know its more work than it needs to be.

As far as I'm aware, you could use one function to do the entire thing and just pull from .txt files for each area and dialogue sequence. I just get mixed up along the way. I still haven't learned how to write classes, which makes it harder.
>>
>>56001374
LuaJIT
>>
>look through the source code of an open source project
>fltk
>there's a trunk folder
>there's a branches folder
>version numbers are inconsistent
Why do they do shit like this?
>>
>>56002276
Algorithms are pretty fun. Go ahead and study it, even if as a hobby or a minor.
>>
>>56002263
tell it to the buds LAD, wrote LAFD for a moment, and amoment too, tell them about me and my humble not so humble story

i need you to hurry up now because i cant wait much longer man
e
hehehe
>>
>>56002548
Yolo
>>
>>56002276
def factorial(n):
return n if n <= 2 else n * factorial(n-1)


FTFY
>>
>>56002276
If you think you will enjoy it then go for it. Are you already in university? If you are unsure you can take Comp Sci 1.
>>
When were you most impressed by a programming language feature?
>>
>people actually decide to implement everything using a single tool and then write books to describe the common patterns that occur when emulating other tools with this one tool
>>
>>56002548
Ah, you're looking at an SVN repo, aren't you
>>
#include <stdio.h>

main()
{
int c;

while ((c = getchar()) != EOF) {
if (c == ' ' || c == '\n' || c == '\t') {
putchar('\n');
}
else {
putchar(c);
}
}
}


this is how I resolved the exercise from "The C programming Language" but looking on the solutions (http://www.eng.uerj.br/~fariasol/disciplinas/LABPROG/C_language/Kernighan_and_Ritchie/solved-exercises/solved-exercises.html/krx112.html) I found some "extra" things. Still my program works, what do I do?
>>
>>56003141
This is the only realistic way for a programmer to become rich.
Trick people into using their shitty language or design paradigm and then make a fortune selling books and consultancy services to large companies.
>>
>>56003206
move on
>>
>>56003206
Your program will print N newlines with N consecutive whitespace characters when it is only supposed to print one.
>>
>>56003233
where do the program gets those Ns?
>>
>>56003274
Stop shitposting and figure it out.
>>
>>56003274
The sample doesn't. It just doesn't print a newline for consecutive whitespace characters. It uses a flag to keep track of this.
>>
Many C++ programmers say they just use high level vectors, lists, etc instead of pointers or arrays.

Do these people not come across fixed size arrays? What sort of software do they write so that they can get away with not having to use pointers or arrays.
>>
>>56003329
Legacy codebases that have no other reason in 2016 to be C++.
>>
>>56003286
ok I got it
practically if my input is four blank spaces, there will be 4 new lines
thanks!
>>
>>56003339
Exactly.
>>
>>55999438
4.9.2
>>
>>56003176
sure am
>>
why wont this code jump into the the while loop at the bottom.

its suposed to check if the line is done and if it is then it will brake out if not it will start work on a new block and then check again if the line is done.

    while line_done == False:

if block_done == True:
if x_point == image_croped_x:
print "line is Done"
line_done = True
break
else:
block_done = False
print "line is not done - State: %r" % line_done
print "block Is starting - State: %r" % block_done

while block_done == False:
>>
>>56003213
this
>>
>>56000779
premature optimizations etc etc fuck you
>>
>>56003400
>GLSL
kill yourself and fuck off to stackoverflow
>>
NEW THREAD!!

>>56003424
>>
>>56003416
GLSL is fucking garbo, thank god all the new APIs have bytecode shaders so you can use an optimizing compiler.
>>
>>56003372
Yeah, see, SVN forces you to structure it that way

One of the many reasons SVN is shit
>>
NON-FAG THREAD:

>>56003443

>>56003443

>>56003443
>>
>>56003388
>== True
>>
>>56003451
Stop spamming the board, you autist.
>>
>>56003329
Using vectors and other data structures is one thing, never using arrays is another.
Never using arrays is just being asinine or lazy.

On the other hand you might have a good reason for avoiding raw pointers, although even Herb Sutter says that there are situations where raw pointers are better than smart pointers.
>>
>>56003451
>HEY GUISE LOOK I MAED A THRED USE MY THRED
Jesus how pathetic can you be
>>
>>56003444
>what is mobile
and the compiler can only do so much regardless of the platform and api, you can still optimize it you lazy fuck, it takes maybe an hour or two to optimize a shader quite well
>>
File: Toshiro-Mifune.jpg (182KB, 1280x733px) Image search: [Google]
Toshiro-Mifune.jpg
182KB, 1280x733px
>>56002882
Can you explain why? I tried your way, it seems to do the same thing for factorials 0 to 10 ad infinitum.
>>
>>56003861
>>56002882
I realize after looking at it a little more, its optimal to use 2 instead of 1, but the optimization is literally just taking (2 - 1) out of the equation when you call factorial(2)
>>
>>55996798
Problem: you have two kinds of geometrical objects, points and lines. Write a function to reflect one object around another.

Statically typed solution:
Point reflect(Point obj, Point pivot);
Point reflect(Point obj, Line pivot);
Line reflect(Line obj, Point pivot);
Line reflect(Line obj, Line pivot);


Dynamically typed solution:
def reflect(obj, pivot):
fun = None
if isinstance(obj, Point):
if isinstance(pivot, Point):
fun = reflectPointAroundPoint
elif isinstance(pivot, Line):
fun = reflectPointAroundLine
elif isinstance(pivot, Line):
if isinstance(pivot, Point):
fun = reflectLineAroundPoint
elif isinstance(pivot, Line):
fun = reflectLineAroundLine
if fun:
return fun(obj, pivot)
return None

def reflectPointAroundPoint:
pass

def reflectPointAroundLine:
pass

def reflectLineAroundPoint:
pass

def reflectLineAroundLine:
pass
>>
File: 18211.png (98KB, 400x300px) Image search: [Google]
18211.png
98KB, 400x300px
>>56004250
>if isinstance
you're not making a very good argument for dynamic typing
>>
>>56004519
Not making an argument for dynamic typing at all.
>>
>>56004519
nvm i guess you're in favor of static typing
>>
>>56004250
I prefer static typing, but couldn't you have in principle a dynamically-typed language where you provide class name or whatever in the function definition, and it dispatches at runtime? Common Lisp must have something like this.
>>
>>56003435
>>56003469
>>56003537
blown the fuck out

nice samefagging btw
>>
I have a chunk system of 512 bytes and I need to set up a read( offset , size ) function that is capable of handling between-block situations Such that Size can span the width of multiple blocks and stop in the middle of one.

If I have a loop that goes through each block id "I" how do I intersect the domain between [CurBlock,CurBlock+512] and [Offset,Offset+Size] so I know how many bytes from CurBlock should be read?
Thread posts: 332
Thread images: 26


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.