Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

You going to explain, or just sit there and :smug:?

Adbot
ADBOT LOVES YOU

darthbob88
Oct 13, 2011

YOSPOS

shrughes posted:

Yes it is. It's iterative.

Well-disguised iteration, then? Because it sure looks like they're recursively calling themselves to solve the subproblem of whether n - 2 or 3 is divisible by 2 or 3. I can see how you'd rewrite that to use a for loop, but you can do that with most recursive solutions.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

shrughes posted:

Yes it is. It's iterative.

In the sense that "recursive" is "iterative plus a stack"? Or did you have some actual insight to share.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

99% sure he's obliquely referring to tail-call optimization that the Scheme interpreter does, which if the student wrote that on a simple modulus problem, likely has no idea exists.

shrughes
Oct 11, 2008

(call/cc call/cc)
It's not tail-call optimization. It's well-defined specified behavior. That's how you write iterative functions in Scheme.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Congratulations on missing the entire point of my original post, then.



EVIDENCE THE STUDENT THOUGHT THEY WERE WRITING A RECURSIVE FUNCTION
  • A function called from within itself
  • A comment next to this call identifying it, in the student's mind, as a recursive call
  • A comment at the top of each function describing its task using the word "recursively"

EVIDENCE THE STUDENT THOUGHT THEY WERE WRITING AN ITERATIVE FUNCTION


e: oh god i'm explaining the joke what am i doing?

carry on then fucked around with this message at 07:09 on Jan 24, 2014

raminasi
Jan 25, 2005

a last drink with no ice
shrughes is pretending to be unaware of what most people mean when they say "recursive" so that he can be smug about having read SICP. Good job, shrughes.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Good to see you're on track to meet your terrible posting quota this month, shrughes!

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.
This code just turned up in some code I'm writing to integrate Crossroads.js with Backbone :(

code:
// Trust me, works great!
Router.extend = Backbone.Model.extend;

Deus Rex
Mar 5, 2005

darthbob88 posted:

Well-disguised iteration, then? Because it sure looks like they're recursively calling themselves to solve the subproblem of whether n - 2 or 3 is divisible by 2 or 3. I can see how you'd rewrite that to use a for loop, but you can do that with most recursive solutions.

I invite you to rewrite that as a for loop in Scheme.

a nest of hornets
Nov 17, 2012

by Ralp
Let's use object subscripting on a ternary operator!

code:
NSDictionary* row = (indexPath.section == 0 ? self.items : self.otherItems)[indexPath.row];
AND both choices are mutable :greatgift:

Athas
Aug 6, 2007

fuck that joker

Internet Janitor posted:

Students are mostly third-year CS students with some experience programming in imperative languages, but many have never used a functional language before.

This is the real horror. How can you be a third-year CS student and not have seen a functional language?

Also, it's cheating to bring in homework code. While correcting operating systems assignments, I've seen bugs you people wouldn't believe. TLBs on fire at the end of a context switch. I watched kernel threads unwittingly created without a stack, as they were functional as long as they never spilled registers or called functions. All that code will be lost in time, like a stack trace in a log file.

Zombywuf
Mar 29, 2008

GrumpyDoctor posted:

shrughes is pretending to be unaware of what most people mean when they say "recursive" so that he can be smug about having read SICP. Good job, shrughes.

He's not even remotely right, recursion is a matter of presentation not compilation result. Otherwise this would be a recursive function:
code:
std::stack s;
for (int i = 0; i < 100; ++i) {
  s.push(i);
}
int tot = 0;
while (!s.empty()) {
  tot += s.top();
  s.pop();
}

Rottbott
Jul 27, 2006
DMC
Just came across this in my travels. It was originally all on one line, presumably for extra surprise value. Ternary misuse isn't a very original horror, but it's kind of elegantly horrible.

code:
var strFrame:String = bEnabled ? bForce ? bFaded ? bSelected ? "focus" : "unfocus" :
bSelected ? "focusFadeOut" : "unfocusFadeOut" : bFaded ? bSelected ? "fadeInFocus" : "fadeIn" :
bSelected ? "fadeOutFocus" : "fadeOut" : bForce ? "disable" : bFaded ? "fadeInDisable" : "fadeOutDisable";

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
I love that there's both "focusFadeOut" and "fadeOutFocus".

shrughes
Oct 11, 2008

(call/cc call/cc)

Zombywuf posted:

He's not even remotely right, recursion is a matter of presentation not compilation result.

It sounds like you don't "get" Scheme. What about this: Is this not iterative?

code:
(define (div3 v)
  (let loop ((i v))
    (if (< i 2)
        (if (= i 0)
            #t
            #f)
        (loop (- i 3)))))

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Athas posted:

I've seen bugs you people wouldn't believe. TLBs on fire at the end of a context switch. I watched kernel threads unwittingly created without a stack, as they were functional as long as they never spilled registers or called functions. All that code will be lost in time, like a stack trace in a log file.

Time... to HCF.

MononcQc
May 29, 2007

shrughes posted:

It sounds like you don't "get" Scheme. What about this: Is this not iterative?

code:
(define (div3 v)
  (let loop ((i v))
    (if (< i 2)
        (if (= i 0)
            #t
            #f)
        (loop (- i 3)))))

What definitions do you go through to define both iteration and recursion? Because it looks like the answer might be both, say you could call it an iterative function defined recursively.

But you're just standing here not even mentioning how you define the meaning you attach to the words you're using, and act superior when people don't agree with you.

It's not an issue of not getting Scheme, it's an issue of not getting you / not expressing oneself clearly enough.

MononcQc fucked around with this message at 17:17 on Jan 24, 2014

celestial teapot
Sep 9, 2003

He asked my religion and I replied "agnostic." He asked how to spell it, and remarked with a sigh: "Well, there are many religions, but I suppose they all worship the same God."
Found in shipped code:

code:
protected void enforceKeyLength() {
        // if given password is too small add our default to it    
        if (mPassword.length() < mKeyLength) {                     
            mPassword = mPassword + "tweedle_dee";                 
        }                                                          
}                                                                  

Pollyanna
Mar 5, 2005

Milk's on them.


Athas posted:

This is the real horror. How can you be a third-year CS student and not have seen a functional language?

When you're a freshman, you're just taking your pre-reqs and maybe a course in your specialty. When you're a sophomore, you start taking your major's funny bits, but you're still stuck in freshman mode and you've also gotten complacent, thinking you're king poo poo of gently caress mountain because hey freshman year was easy peasy. Then, when you're a junior and you're expected to start working on Real Major poo poo, you're like "what the gently caress" cause this is stuff you've barely ever done for the past two years.

That's how.

Pie Colony
Dec 8, 2006
I AM SUCH A FUCKUP THAT I CAN'T EVEN POST IN AN E/N THREAD I STARTED

Athas posted:

This is the real horror. How can you be a third-year CS student and not have seen a functional language?

Also, it's cheating to bring in homework code. While correcting operating systems assignments, I've seen bugs you people wouldn't believe. TLBs on fire at the end of a context switch. I watched kernel threads unwittingly created without a stack, as they were functional as long as they never spilled registers or called functions. All that code will be lost in time, like a stack trace in a log file.

that's ridiculous. at my school, two years worth of courses would have gotten you intro to CS, data structures, operating systems, computer architecture, some electives and MAYBE algorithms (though it was intended for a first semester 3rd year course). where exactly do you expect ALL computer science students to learn functional programming? not everyone has been coding since 12 and not everyone goes home to just to program in languages they don't learn in class.

(i should also state my school, like a lot of other schools, goes with java as the introductory language instead of like scheme or something)

Pie Colony fucked around with this message at 18:14 on Jan 24, 2014

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Athas posted:

This is the real horror. How can you be a third-year CS student and not have seen a functional language?

All of my courses were in C++ or Java and now I wish they'd made me learn a functional language back in the day so I'd be less poo poo with them now :smith:

Strong Sauce
Jul 2, 2003

You know I am not really your father.





celestial teapot posted:

Found in shipped code:

code:
protected void enforceKeyLength() {
        // if given password is too small add our default to it    
        if (mPassword.length() < mKeyLength) {                     
            mPassword = mPassword + "tweedle_dee";                 
        }                                                          
}                                                                  

I don't know why but I find this really hilarious

Pollyanna posted:

When you're a freshman, you're just taking your pre-reqs and maybe a course in your specialty. When you're a sophomore, you start taking your major's funny bits, but you're still stuck in freshman mode and you've also gotten complacent, thinking you're king poo poo of gently caress mountain because hey freshman year was easy peasy. Then, when you're a junior and you're expected to start working on Real Major poo poo, you're like "what the gently caress" cause this is stuff you've barely ever done for the past two years.

That's how.
Are you actually describing your own experiences or what you view how CS courses go? This doesn't sound right at all.

Sebbe
Feb 29, 2004

Pie Colony posted:

that's ridiculous. at my school, two years worth of courses would have gotten you intro to CS, data structures, operating systems, computer architecture, some electives and MAYBE algorithms (though it was intended for a first semester 3rd year course). where exactly do you expect ALL computer science students to learn functional programming? not everyone has been coding since 12 and not everyone goes home to just to program in languages they don't learn in class.

In our first two years we have mandatory courses on functional programming (very first course on the bachelor level, in fact), algorithms/data structures, operating systems, compilers, networking, object-oriented programming, databases, human-computer interaction as well as a project course. (As well as the necessary math courses.) This leaves a bit of room for electives, though most of the room for those is on the third year.

The functional programming is reinforced in the compilers course, where the compiler is built in a functional language as well.

It is very much doable - and being done at our univeristy. :) It all depends on how highly you value functional programming.

Sebbe fucked around with this message at 18:19 on Jan 24, 2014

Pie Colony
Dec 8, 2006
I AM SUCH A FUCKUP THAT I CAN'T EVEN POST IN AN E/N THREAD I STARTED
can you post one of these compilers made by a sophomore?

e: i don't really imagine a sophomore understanding CFGs, LL/LR parsing, type checkers, register allocation, garbage collection, or anything that goes into making a compiler. unless you just meant you read chapter 5 from SICP.

my school's program definitely wasn't the best but it's a fairly well known school and probably represents the type of education you can get from a typical non-elite school.

Pie Colony fucked around with this message at 18:50 on Jan 24, 2014

Workaday Wizard
Oct 23, 2009

by Pragmatica

Strong Sauce posted:

Are you actually describing your own experiences or what you view how CS courses go? This doesn't sound right at all.

Actually she is right. Freshman and Sophomore year are usually full of 101 courses from different unrelated majors (mandatory electives).

Also, CS programs have many courses that require prerequisites and as such you can't take them early.

Not to mention scheduling problems, professor availability, and seat availability.

Mogomra
Nov 5, 2005

simply having a wonderful time

Shinku ABOOKEN posted:

Actually she is right. Freshman and Sophomore year are usually full of 101 courses from different unrelated majors (mandatory electives).

Also, CS programs have many courses that require prerequisites and as such you can't take them early.

Not to mention scheduling problems, professor availability, and seat availability.

This was exactly my experience. There were only a few semesters near the end that I thought I was actually focusing on computery related stuff.

E: True, I'm just saying, "Yes that kind of thing definitely does happen."
VVV

Mogomra fucked around with this message at 18:47 on Jan 24, 2014

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Shinku ABOOKEN posted:

Actually she is right. Freshman and Sophomore year are usually full of 101 courses from different unrelated majors (mandatory electives).

Also, CS programs have many courses that require prerequisites and as such you can't take them early.

Thus the case for the maintenance or reintroduction of weedout courses, so that people don't roll into junior and senior courses and poo poo the bed


e:

Mogomra posted:

This was exactly my experience. There were only a few semesters near the end that I thought I was actually focusing on computery related stuff.

This will vary tremendously from place to place

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Oddly enough how classes are distributed varies a lot between schools. My freshman and senior years were almost entirely CS classes, my junior year was almost entirely GEs, and sophomore year was a mix. Two years of GEs followed by two years of in-major classes seems to mostly be a large public university thing.

Don Mega
Nov 26, 2005
At my university you typically took 2 cs coursers per semester and if desired could take more or less.

nielsm
Jun 1, 2009



Pie Colony posted:

can you post one of these compilers made by a sophomore?

Based on Sebbe's description of the curriculum (and his profile page) it sounds very much like DIKU. I suppose I can just post the code I turned in for the compiler course there in January 2005. Bunch of Standard ML files (for the Moscow ML interpreter suite.) Some parts of that code was supplied by the lector, in particular the file I/O stuff and some of the constants used for generating the MIPS assembly output. The register allocator might also have been supplied. The input language is a Pascal-like.

E: Eh turns out I haven't touched SML for 8+ years and forgot a couple files in that archive. It's a small miracle I could even find those files. Fill in the blanks.

nielsm fucked around with this message at 19:07 on Jan 24, 2014

Sebbe
Feb 29, 2004

nielsm posted:

Based on Sebbe's description of the curriculum (and his profile page) it sounds very much like DIKU. I suppose I can just post the code I turned in for the compiler course there in January 2005. Bunch of Standard ML files (for the Moscow ML interpreter suite.) Some parts of that code was supplied by the lector, in particular the file I/O stuff and some of the constants used for generating the MIPS assembly output. The register allocator might also have been supplied. The input language is a Pascal-like.

E: Eh turns out I haven't touched SML for 8+ years and forgot a couple files in that archive. It's a small miracle I could even find those files. Fill in the blanks.

Indeed it is DIKU. It follows the book Basics of Compiler Design, which pretty much was written for use on the course.

Each year, a basic compiler for a subset of a language is handed out. The students then extend this compiler with new features, working in groups. The exam again is extending the compiler, this time on their own, with some more features.

Here's my group's compiler from 3 years ago. Each year it's a new language. Quite fun course.

Edit: The problem statement (G-opgave.pdf) is there, too, if you can read Danish.

Sebbe fucked around with this message at 19:30 on Jan 24, 2014

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Plorkyeran posted:

Oddly enough how classes are distributed varies a lot between schools. My freshman and senior years were almost entirely CS classes, my junior year was almost entirely GEs, and sophomore year was a mix. Two years of GEs followed by two years of in-major classes seems to mostly be a large public university thing.

At mine it's basically three semesters of one or maybe two intro CS classes per semester until you pass the introductory data structures course in your third semester, then a mad dash to grab all required classes plus about 7 CS electives, the finish up GE classes you might have not gotten to while you were stuck waiting to pass DS.

Could be better, but I've enjoyed my all CS semesters well enough.

Deus Rex
Mar 5, 2005

Pie Colony posted:

that's ridiculous. at my school, two years worth of courses would have gotten you intro to CS, data structures, operating systems, computer architecture, some electives and MAYBE algorithms (though it was intended for a first semester 3rd year course). where exactly do you expect ALL computer science students to learn functional programming? not everyone has been coding since 12 and not everyone goes home to just to program in languages they don't learn in class.

(i should also state my school, like a lot of other schools, goes with java as the introductory language instead of like scheme or something)

my school did about a 50/50 mix of Java and Scheme in the first year CS courses.

nuvan
Mar 29, 2008

And the gentle call of the feral 3am "Everything is going so well you can't help but panic."
When I signed up at my school, we had to take 2 Physics courses, Calculus (differential and integral), Linear Algebra, Combinatorics, a bunch of CS courses, and then enough electives to get to 120 credit hours. Since then they've added additional breadth requirements.

Deus Rex posted:

my school did about a 50/50 mix of Java and Scheme in the first year CS courses.

Cool that you got to use a functional language outside of a course on that type of language. At my school, everything was Java, except for a course on Functional and Logical Programming, covering Standard ML, Racket, and Prolog. I wonder how it would be to go through a CS degree where everything was SML/Scheme/some_other_functional_language, except for a course on Imperative and Object-oriented programming?

zergstain
Dec 15, 2005

Pie Colony posted:

that's ridiculous. at my school, two years worth of courses would have gotten you intro to CS, data structures, operating systems, computer architecture, some electives and MAYBE algorithms (though it was intended for a first semester 3rd year course). where exactly do you expect ALL computer science students to learn functional programming? not everyone has been coding since 12 and not everyone goes home to just to program in languages they don't learn in class.

(i should also state my school, like a lot of other schools, goes with java as the introductory language instead of like scheme or something)

Sounds mostly like mine. First year you get intro to programming, intermediate programming, discrete structures 1, calculus 1, and six electives. We do five classes a semester. Second year is data structures, computer architecture, OO, discrete structures 2, algorithms, software systems development (this one is notorious for its high failure rate), operating systems. Third and fourth is mostly electives, but we have to take classes in system analysis and design, software engineering, theory of computation, and either statistics 1 or modelling of computer systems. Compilers was made a requirement for students starting in 2013.

Most classes are in C. Java is used for OO. And we've done some Python.

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Athas posted:

This is the real horror. How can you be a third-year CS student and not have seen a functional language?
The US teems with colleges that have unaccredited CS departments whose focus is vocational. It's not that I didn't know there were functional languages during my undergrad program, but nobody on the faculty was repping for them, and if you concluded that therefore they must be a research dead end nobody was going to challenge that conclusion.

Gazpacho fucked around with this message at 08:19 on Jan 25, 2014

evensevenone
May 12, 2001
Glass is a solid.
I don't think it's really that surprising. Functional languages are kind of trendy for first-year CS education right now, but it's hardly all schools that do it that way or some kind of fundamental requirement of a CS program. Lots of places still use Java or some combination of Python, C and C++. Some places even use Lisp.

And if the intro courses aren't in a functional language, then probably the only courses that would use it are upper division electives that not everyone takes.

Master_Odin
Apr 15, 2010

My spear never misses its mark...

ladies

Gazpacho posted:

The US teems with colleges that have unaccredited CS departments whose focus is vocational. It's not that I didn't know there were functional languages during my undergrad program, but nobody on the faculty was repping for them, and if you concluded that therefore they must be a research dead end nobody was going to challenge that conclusion.
The CS department can be accredited and have this happen. Granted, my department was pretty small (and took like 3-4 years to replace two professors who left) so of course there was tons of scheduling conflicts and stuff (and of course the requirement being Theory of Computation OR programming languages).

Of cousre, my "introductory" course (though it was CS 1&2 bundled together) used Scratch for a bit into Processing with zero focus on data structures that everyone who took CS2 had. :suicide:

Adbot
ADBOT LOVES YOU

Smugdog Millionaire
Sep 14, 2002

8) Blame Icefrog

quote:

Note: The electronic payment system is unavailable due to weekly maintenance from 11 p.m. on Friday until 9 a.m. on Saturday.

Not sure why a website should need 10 hours of weekly downtime for maintenance.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply