Virtudyne Scheme



  • My friend showed me what he submitted for his Intro to Programming lab in college, which is taught in scheme.

     

    The assignment was:

    Exercises

    A company maintains several pieces of information about its employees: their name, hourly salary, the names of projects they work on (could be several, like database, web, service), and which (other) employees they supervise. A person may work on different projects than his or her boss.

    1. Develop a data definition and two examples of data for company employee hierarchies. The hierarchy should start with a single person (the boss). (The data for who each person supervises should be other employees, not just those employees' names.)

    2. Provide the template for an employee hierarchy.

    3. Write a function everyone-busy? that consumes an employee hierarchy and produces a boolean indicating whether every person in the company is working on at least one project.

     

    His solution:

    ;; Problem 1

    ;; an employee is a (make-employee string number list-of-string
    ;; list-of-employee)
    (define-struct employee (name salary projects underlings))

    ;; a list-of-string is either;
    ;; empty, or
    ;; (cons string list-of-string)

    ;; a list-of-employee is either;
    ;; empty, or
    ;; (cons employee list-of-employee)

    ;; Examples
    (define WebDeveloper (make-employee "Sam" 15.00 (list "web") empty))
    (define WebLeadDeveloper (make-employee "Joe" 18.00 (list "web" "database") (list WebDeveloper)))
    (define WebSupervisor (make-employee "John" 20.00 (list "web" "service") (list WebLeadDeveloper)))
    (define WebVP (make-employee "Fred" 22.00 (list "database" "quality control") empty))
    (define WebBoss (make-employee "Trogdor" 25.00 (list "management") (list WebVP WebSupervisor)))
    (define WebGroup WebBoss)

    (define VirtuJanitor (make-employee "The Janitor" 300.00 (list "cleaning") empty))
    (define VirtuJunior (make-employee "Junior" 400.00 (list "sales" "morale officer" "security") (list VirtuJanitor)))
    (define VirtuVP (make-employee "The VP of Nothing" 400.00 empty empty))
    (define VirtuSavior (make-employee "The Savior" 500.00 (list "benefacting") (list VirtuVP VirtuJunior)))
    (define VirtuCIO (make-employee "The CIO"  500.00 (list "magic") (list VirtuSavior)))
    (define VirtuFounder (make-employee "The Founder" 750.00 (list "consulting") (list VirtuCIO RobGraves)))
    (define RobGraves (make-employee "Rob Graves" 13.37 (list "design" "development" "implementation") empty))
    (define Virtudyne VirtuFounder)


    ;; Problem 2

    ; ;; company-func/employee: employee -> ?
    ; ;; ?
    ; (define (dtree-func/employee anemp)
    ;   (employee-name anemp)
    ;   (employee-salary anemp)
    ;   (projects-func/list (employee-projects anemp))
    ;   (company-func/elist (employee-underlings anemp)))
    ;
    ; ;; company-func/elist: list-of-employee -> ?
    ; ;; ?
    ; (define (company-func/elist aloe)
    ;   (cond [(empty? aloe)   ]
    ;         [(cons? aloe) (company-func/employee (first aloe))
    ;                       (company-func/elist (rest aloe))]))
    ;
    ; ;; projects-func/list: list-of-projects -> ?
    ; ;; ?
    ; (define (projects-func/list alop)
    ;   (cond [(empty? alop)   ]
    ;         [(cons? alop) (   (first alop))
    ;                       (project-func/list (rest alop))]))
    ;



    ;; Problem 3

    ;; everyone-busy?: employee -> boolean
    ;; consumes an employee hierarchy and produces a boolean indicating
    ;; whether every person in the company is working on at least one project.
    (define (everyone-busy? anemp)
      (cond
        [(empty? (employee-projects anemp)) false]
        [(cons? (employee-projects anemp))
         (anyone-busy? (employee-underlings anemp))]))

    ;; anyone-busy?: list-of-employee -> boolean
    ;; consumes a list-of-employee and produces a boolean indicating
    ;; whether every person in the company is working on at least one project.
    (define (anyone-busy? aloe)
      (cond [(empty? aloe) true ]
            [(cons? aloe) (and (everyone-busy? (first aloe))
                          (anyone-busy? (rest aloe)))]))

    ;; Test Cases
    (everyone-busy? WebGroup) "expects" true
    (everyone-busy? Virtudyne) "expects" false

     

     

    Will follow up with a grade in a few days. Wonder if the professor is familiar with Virtudyne? 



  • Not bad, but anyone-busy? is misleadingly named.  I would suggest everyone-in-this-list-busy? as a replacement.

     



  • Why would you teach "Intro to programming" in scheme?  I'd think pretty much any language with C-esque syntax would be more appropriate.

    I can see the appeal of getting people off on the right foot, as using a functional language means students are less likely to develop the nasty "all my functions have side effects, and every variable is global!" habit.  But how about teaching a language that'll actually see real world use?
     



  • Trogdor only makes $25/hour?  He wouldn't burninate for that...

     



  • @merreborn said:

    Why would you teach "Intro to programming" in scheme?

    A typical course is based not on how things really work, but on how the lecturer would like things to work. While it is possible to learn a great deal at university, you must always remember that in any given course you are learning the lecturer's own version of it - and they are most likely an ivory-tower academic. Also, universities do not exist for the purpose of preparing people to work in industry, they exist for the purpose of preparing people to work in universities. Any benefits gained by people who intend to work in industry are purely coincidental.

    You would teach "intro to programming" in scheme if you wanted there to be more scheme programmers in universities. It's that simple.



  • @merreborn said:

    But how about teaching a language that'll actually see real world use? 

    While I think that scheme is an odd place to start, I'd be worried about any university comp sci program that didn't have it's students learning less than a half-dozen languages, not all of them are going to be 'real world'.  You learn different things from different programming techniques. 

    And really, you could find fault in pretty much any language you choose to start people with.  Traditionally, people got hit with C first, because god knows you want 1st semester newbies trying to wrap their heads around pointers <-> arrays <-> strings.

    -cw



  • @asuffield said:

    @merreborn said:

    Why would you teach "Intro to programming" in scheme?

    A typical course is based not on how things really work, but on how the lecturer would like things to work. While it is possible to learn a great deal at university, you must always remember that in any given course you are learning the lecturer's own version of it - and they are most likely an ivory-tower academic. Also, universities do not exist for the purpose of preparing people to work in industry, they exist for the purpose of preparing people to work in universities. Any benefits gained by people who intend to work in industry are purely coincidental.

    You would teach "intro to programming" in scheme if you wanted there to be more scheme programmers in universities. It's that simple.



    Scheme is a great introductory language for a Computer Science curriculum. However, it's a horrible introductory language for a Software Engineering curriculum. That most people discussing or even pursuing a CS curriculum really mean Software Engineering is an unfortunate situation.  But anyway, scheme exposes language design concepts more readily than C++ or Java, and results in fugly, yet simple and elegant example code.

     



  • @obediah said:

    Scheme is a great introductory language for a Computer Science curriculum.

    Haskell or some kind of ML is better, from an objective standpoint. All the advantages, less of the crud, and Haskell in particular is even closer to pure CS. (In fact, you could do most of a CS course just studying the Haskell language and compilers - all the important stuff is in there)

     

    That most people discussing or even pursuing a CS curriculum really mean Software Engineering is an unfortunate situation. 

    My degree was in computer engineering. Does that make me psychotic?



  • @asuffield said:

    @obediah said:

    Scheme is a great introductory language for a Computer Science curriculum.

    Haskell or some kind of ML is better, from an objective standpoint. All the advantages, less of the crud, and Haskell in particular is even closer to pure CS. (In fact, you could do most of a CS course just studying the Haskell language and compilers - all the important stuff is in there)

     

    That most people discussing or even pursuing a CS curriculum really mean Software Engineering is an unfortunate situation. 

    My degree was in computer engineering. Does that make me psychotic?

    I had a friend that had to do Eisel (i think that's pronounced right)... it's some AI programming language (which i just found out that Lisp is good for)

    Then he got shipped to some place in new york to write a big eisel program...

    Weird.



  • @GeneWitch said:

    I had a friend that had to do Eisel (i think that's pronounced right)... it's some AI programming language (which i just found out that Lisp is good for)

    Then he got shipped to some place in new york to write a big eisel program...

    Weird.

    It wasn't this program, was it? 


Log in to reply