Coder Social home page Coder Social logo

crista / exercises-in-programming-style Goto Github PK

View Code? Open in Web Editor NEW
2.0K 88.0 551.0 639 KB

Comprehensive collection of programming styles using a simple computational task, term frequency

License: MIT License

Python 90.04% Makefile 0.06% Clojure 0.98% C++ 2.13% Shell 1.19% Scala 1.77% Java 2.91% Ruby 0.15% REXX 0.78%

exercises-in-programming-style's Introduction

Exercises in Programming Style

Comprehensive collection of well-known, and not so well-known, programming styles using a simple computational task, term frequency. All programs run with the following command line:

python tf-NN.py ../pride-and-prejudice.txt

NOTE: the code in the master branch is written for Python 3. If you are looking for a version for Python 2.7, check out the 2.7 branch or the v1.0 release.

Explanations and historical context for all these styles can be found in the companion book Exercises in Programming Style.

Additions are welcome!

You can contribute:

  • new exercises related to the existing styles
  • an entirely new programming style
  • new names for the existing styles
  • discussion of names, pros and cons of each style

Because this project and the companion book are used in courses, at the suggestion of several students I am no longer accepting contributions of the existing styles written in different programming languages. That is the first exercise that the students do. Having the solutions easily available here will rob future students of the learning experience!

Please follow the conventions suggested by the existing code base, specifically, if you are contributing a new style, make a new folder called nn-funname and add an example program in that folder called tf-nn.ext. (nn is the next avalaible number in the collection) Additionally, add a README.md file that clearly describes the contraints for writing programs in that style. I will only consider new styles corresponding to constraints that are clearly different from the ones that already exist in the collection. (different programs written in existing styles are exercises for students, and should not be here)

Contributions of new names and discussion should be done under Issues or on the Wiki part of this repo.

To test your work, make sure your script is executable and then run:

./test/test.sh NN

Where NN is the number prefix of the directory you're adding.

Never stop exercising!

Love, Crista

P.S. Inspiration for this collection: http://en.wikipedia.org/wiki/Exercises_in_Style

exercises-in-programming-style's People

Contributors

amcheng avatar aphyr avatar bmistree avatar bravelittlescientist avatar bruceadams avatar chadwhitacre avatar crista avatar darius avatar davidfstr avatar ericandrewlewis avatar hukun01 avatar imarudina avatar j10sanders avatar jedelbo avatar jmaccabe avatar kdabiria avatar mgiorgio avatar rtoal avatar rvdheij avatar sivabalan avatar smtriplett avatar tingstad avatar windows81 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

exercises-in-programming-style's Issues

Would there be solutions?

I can sense that the exercises if solved will be helpful, but i just can't figure out how to do the exercise converting TFTheOne class into functions and editting wrap and bind. The hint/specifications are insufficient for me to start.

Does anyone have examples of the exercises solved?

Need help with 'Good Old Times'

Okay, I am so utterly confused! I'm trying very hard to figure this lesson out and I felt like I haven't learned anything except how to put parentheses in 'print'. Here is what I am having trouble with:

  1. How do you filter the characters in Part 1?
  2. It says to read the input file. What input file?
  3. Another instruction says to find 25 frequency words in Part 2. What 25 frequency words?
  4. How do you load the list of stop words?
  5. How do you loop over the secondary memory file?
  6. When I ran the lesson in my Python program, the message said that the stop_words.txt is not found. How do I fix this?

Good old times has an incorrect line

del data[:]

As far as I know, this line would not have the desired effect of clearing the data memory. The slice notation Python makes a copy of the data. So that's not what we want. To fit in with the rest of the code and allow old data to be garbage collected, just assign an empty list to the data variable.

More programming languages

I just saw yr talk of the JoC conference.

Now I found that the "pipeline" style comes in several languages but the other ones I checked out didn't. Is there a reason for this?

For yr talk I learned you do assignments in a course you teach, where students pick a not-Python (maybe also non-Prolog???) language to "port" all the exercises to.

Would it be an idea to merge this project into the Rosetta Stone of programming languages? Your students probably already did most of the work already :)

34: "the C flow" name correct?

The constraints seem contrary to C-style programming. We love those early returns and efficient breaks, e.g. terminate a search loop.

I remember these constraints as a style called "single entry, single exit", with the additional constraint that there can only be a single return statement. This usually results in the possible return value being stored in a variable first.

Cool project. Good luck with the book.

data[1] doesn't need to be a list

In Good Old Times, data[1] doesn't need to be a list because the list always only has one item. It can be changed to str instead.

Method chaining, aka fluent interface?

Has this style been covered?

Though it applies strictly to OOP it's very popular these days, particular in testing, SQL, and javascript (jQuery, Underscore).

Python 2 vs Python 3

All of the Python examples are written in Python 2 instead of Python 3. I think it would be a good idea to encourage the use of Python 3 in newly written materials given that Python 2 has been feature-frozen since July 2010. Python 3 is the future.

Did you have a specific reason around using Python 2?

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.