|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On February 26 2017 04:30 DickMcFanny wrote: Sorry if that's a stupid question, but how do I express iteration in JS?
Let's say I have a quadratic formula, f(x) = x^2 + 1. f(0) = 1, so the next step is to find out f(1), which is 2, so the next step is to find f(2), which is 5, so the next step is to find f(5), which is 26, so the next step is to find f(26) and so on.
I'm not sure what I should even google, neither in German nor English. This isn't even a recursive function declaration. What exactly are you trying to do? If you want to calculate f for a single given x, just write r = x*x + 1. No need to iterate anything. If you want the result for ALL x in {0, 1, 2, ...}, then use a for/while loop. Though I don't see a reason why you would want that.
|
Well I'm not interested in {0, 1, 2, 3... } for x, I'm interested in {0, 1, 2, 5...}.
You're suggesting I just let it calculate every value of x, but I'm interested to see how iteration works in the quadratic formula. So f(3) would be of no interest because 3=x is not the result of a former function.
|
Germany2686 Posts
I'm not sure I understand, but you can try this:
const f = (n) => Math.pow(n, 2) + 1
let x = 0
while (x < 10) { x = f(x) console.log(x) }
|
On February 26 2017 05:24 DickMcFanny wrote: Well I'm not interested in {0, 1, 2, 3... } for x, I'm interested in {0, 1, 2, 5...}.
You're suggesting I just let it calculate every value of x, but I'm interested to see how iteration works in the quadratic formula. So f(3) would be of no interest because 3=x is not the result of a former function. Ok, I see. Your function should then be defined as
f(n) = f(n-1)^2 + 1 f(0) = 0 Which makes it a proper recursive function. Which you can evaluate with both a loop that replaces the value of some variable with each iteration, or with an actual recursive function call. Both have been posted before.
|
Yeah, both of the suggestions that have been posted work, thanks. Got some really interesting numbers, will come in handy when I learn more about fractals.
Where would I start if I wanted to take these figures and display them in an XY plane?
|
Germany2686 Posts
|
|
anyone know a good flask/django alternative in Haskell?
|
|
whats up with the new thread name?:O
EDIT: Nvm, this thread name couldn't have been more accurate.
|
I need help with a C issue
I am using strstr to find a substring
and I am replacing that substring with the same string, except in brackets
so like, I find "how" in the sentence: "I wonder how do I do this"
and I replace it with [how]:
"I wonder [how] I do this"
the problem is that I am sometimes replacing it multiple times in a string, so I need to loop through and do it again but strstr just immediately finds the "how" inside of "[how]" and then my code makes the sentence
"I wonder [[how]] I do this"
edit: I guess I can set a pointer as a marker to the end of the last correction, and if my marker isn't null then I move to the end of my marker for the next strstr ?
pointers are pretty weird. I've decided to use 2 pointer "markers. I'll start with them both null, and then deal with 3 cases
case 1: the yare both null. then I will set the first market to strstr(my string, my target) case 2: 2nd marker is null. then set marker 2 to strstr(marker 1, target) case 3: 1st marker is null. then set marker 1 to strstr(marker 2, target)
I think this should work.
edit2: OMFG I GOT IT TO WORK. IVE BEEN WORKING ON THIS FOR SO LONG, LOL
|
On February 26 2017 12:02 aRyuujin wrote: anyone know a good flask/django alternative in Haskell? As Hanh said, Yesod is a good django replacement. Scotty and spock seem closer to flask though.
|
On February 27 2017 00:29 Prillan wrote:Show nested quote +On February 26 2017 12:02 aRyuujin wrote: anyone know a good flask/django alternative in Haskell? As Hanh said, Yesod is a good django replacement. Scotty and spock seem closer to flask though.
I've heard of Yesod before (could never find a working pdf of the oreilly book), but Scotty seems to be what I need.
Thanks to both of you
|
Don't forget snap as a web framework for haskell.
|
|
I am pretty frustrated For my interview with amazon, I was sent an email and had to RSVP to a 2.5 hour coding assessment. I assume they invite however many students through it, and it's a series of challenges.
I followed the link to the RSVP and filled stuff out, and then when it was time to click if I could make the time or not, I somehow clicked "I can't make this time". I really don't know how... I really feel like I clicked the right thing but whatever.
So anyways it takes me to the next page, and i want to go back, and there was literally no way to go back in the form. The only option I had was to fill out as my reason for not making it "I do want to RSVP, I misclicked and can't go back in the form."
I emailed the recruiter about it but I just have this bad feeling he's never gonna check the email and I am going to miss the event.
You're supposed to have RSVP'd by the end of the day today, too..
|
Thats quite shitty, AFAIK you don't have to but I never really used it.
|
module Snap.Internal.Util.FileServe ( -- * Helper functions getSafePath -- * Configuration for directory serving , MimeMap , HandlerMap , DirectoryConfig(..) , simpleDirectoryConfig , defaultDirectoryConfig , fancyDirectoryConfig , defaultIndexGenerator , defaultMimeTypes , fileType -- * File servers , serveDirectory , serveDirectoryWith , serveFile , serveFileAs -- * Internal functions , decodeFilePath ) where
I forgot where but I remember reading or watching something where someone got mad at how so many programmers seem to have random coding preferences, like putting the comma in front. I get why, but I still find it hilarious to look at.
On February 28 2017 05:32 travis wrote: I am pretty frustrated For my interview with amazon, I was sent an email and had to RSVP to a 2.5 hour coding assessment. I assume they invite however many students through it, and it's a series of challenges.
I followed the link to the RSVP and filled stuff out, and then when it was time to click if I could make the time or not, I somehow clicked "I can't make this time". I really don't know how... I really feel like I clicked the right thing but whatever.
So anyways it takes me to the next page, and i want to go back, and there was literally no way to go back in the form. The only option I had was to fill out as my reason for not making it "I do want to RSVP, I misclicked and can't go back in the form."
I emailed the recruiter about it but I just have this bad feeling he's never gonna check the email and I am going to miss the event.
You're supposed to have RSVP'd by the end of the day today, too..
First off, nice job on getting something with Amazon. Hope it still goes well.
To be frank though, besides Amazon being an extremely hit or miss software opportunity, Amazon also has consistently one of the worst recruiting departments out of every technology company you could encounter. That includes lots of anecdotes from interviewees such as: recruiters taking 3 weeks to respond to emails, receiving offers and declines up to 3 months after interviewing, weeks before feedback from the coding assessment, and more.
While it is your first? big job opportunity, I would honestly not even consider interviewing for Amazon, let alone working there, given all these problems. So while it does suck messing up somewhat, I wouldn't take it too hard for a company like Amazon.
|
I forgot where but I remember reading or watching something where someone got mad at how so many programmers seem to have random coding preferences, like putting the comma in front. I get why, but I still find it hilarious to look at.
What is funny? The people who get mad or the comma in front?
|
On February 28 2017 08:59 Hanh wrote:Show nested quote + I forgot where but I remember reading or watching something where someone got mad at how so many programmers seem to have random coding preferences, like putting the comma in front. I get why, but I still find it hilarious to look at.
What is funny? The people who get mad or the comma in front?
The thing I referenced was a funny rant.
I personally think commas in front look hilarious.
|
|
|
|