Giter VIP home page Giter VIP logo

ironyard_exercises's Introduction

Ironyard Exercises

EXTRA CREDIT (added 3/5/15)

In JavaScript, given a set of arrays, write a program that will tell me which arrays contain all the members of the other array:

var array1 = [
  { name: 'John', age: 25},
  { name: 'Jane', age: 58},
  { name: 'Josh', age: 12}
]

var array2 = [
  { name: 'Jane', age: 58},
  { name: 'John', age: 25}
]

var array3 = [
  { name: 'John', age: 25},
  { name: 'Jane', age: 58}           
]

In this case array2 and array3 are the same but in a different order, but array1 is not fully contained within array2 (missing Josh). An example API might look like:

array1IsASubsetOf(array2) // false
array2IsASubsetOf(array3) // true
array2IsASubsetOf(array1) // true

Write this program in less than five lines of (readable, less than 80 columns wide) code with underscore as the only dependency and I will buy you lunch (limit 2 first successful attempts). While the main assignment is intended to be done in groups, this is a solo effort and I will ask for your answers on Tuesday. Thanks! See you then.


Homework for Jed's lecture on Functional Programming

How To

Functional Programming is a different way of thinking than Procedural or Object Oriented programming. Spend some time learning how these three styles differ (wikipedia might be a great start) and do your best to try to implement these as described below.

It turns out that Ruby can be more functional (like LISP) than you might think .

  • solve the problem in Ruby (you need MiniTest installed gem install minitest)

    • in an imperative/procedural fashion
    • in a functional fashion (hint: use the Eunumerable module)
    • in an object oriented fashion
  • solve the problem in JavaScript (uses the jasmine-node testing framework—see Running JS Tests below)

    • to the best of your ability without dependencies
    • with Underscore as a utility library

Solutions have been given, but it doesn't mean they are the best solutions. My advice is to delete the file contents and work your way through the problems yourselves. (I hear Nick is giving creativity points.)

Yes, you may work in groups. No the homework is not graded, but you won't get much out of the lecture if you have not done this prep and that would be a waste of time for me and you. If you work with others, be sure you understand the language decisions made.

Running JS Tests

  1. If you don't have npm installed, run $ brew install npm.
  2. Install jasmine-node. To install it globally, run $ npm install -g jasmine-node.
  3. To run the tests:
  • From inside anagram_javascript, run $ jasmine-node .
  • From inside anagram_coffeescript, run $ jasmine-node . --coffee.

Discussion

Come to the lecture 9/19 ready to discuss the following questions.

  • What solution in Ruby do you like best? Why?
  • Are there patterns from your Ruby solutions that lend themselves to JavaScript solutions?
  • Are there conveniences in Ruby you wish you had in JavaScript? Why?

Feedback/Questions

Open a github issue. I'll gladly answer any questions.

Credits

Both problems take from exercism.io but problems in that application are served rather than picked so this just uses a problem that is solved in roughly equal terms in several languages.

ironyard_exercises's People

Contributors

jedschneider avatar tnez avatar posgarou avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.