Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Wednesday, April 11, 2012

Survey of Software Developers, re: Tools

InfoGraphic: A survey of former Berkeley students now in the software industry concerning programming languages, etc.

Note that the leading development platform is cloud computing.

Monday, January 30, 2012

Scale of the Universe (Flash)

..., Exometers, Petameters, Terameters, . . ., Meters, ...,  Picometers, Femtometers, Attometers, ...

"This is an interactive flash animation that lets you zoom in and out on objects in the universe to get a sense for their relative sizes.  Who knew that a giant earthworm could grow to be 7 meters long!"

Tuesday, November 30, 2010

Pig Latin Encoder

To encode a word in pig latin, we need to handle two cases as described on p. 277.

The following function is a partial (but not complete) solution.

For example, how does it encode swing? rhythm? Aardvaark? CIS?

/* return word w encoded as pig latin */
function encode(w){
if(w.search(/[aeiou]/) == -1 || w.search(/[aeiou]/) == 0)
return w + 'way'
else
return w.substring(1, w.length) + w.charAt(0) + 'ay'
}

MISC PIG LATIN NOTES

var w = 'oops!!'
var punct, bareWord, pLatin, ans

//peel off punctuation
punct = w.substring(w.search(/[!,.]/), w.length)
bareWord = w.substring(0, w.search(/[!,.]/))

pLatin = encode(bareword)

ans = pLatin + punct

Test Cases:

Eighthstreet, gym, myrrh, aeon, llama, kvetch.

gnome, bloom, brew, clue, snow, smart, wrench.

rhythm, crypt, rhyme, gypsy, strength, scrimp, shrimp, schlep, shrapnel, splice, sphygmomanometer, strap, scrap, spring,

Pig Latin koans: Xylophone, tsktsk, eau de Cologne.
Enhanced by Zemanta

Sunday, November 28, 2010

Final Exam Review Problems

final examsImage by sashamd via Flickr

  • (1) Write an alarmClock() function that accepts an integer representing the day of the week (Mon=1, Tue=2, ... Sun=7) and returns a string: On weekdays the clock tells us to get up, and weekends it tells us to snooze more. On Monday, the clock adds some extra harassment to get us out of bed.

    Examples

    alarmClock(2) => Hi ho, hi ho, it's off to school we go...

    alarmClock(6) => Hit the snooze button!

    alarmClock(1) => Daylight in the swamps! Up and at'em!

    Strategy: Use an else-if (See fig. 11.7, p. 203; dice.html)

  • _______________________________________________

    (2) Write a bowlingScoreFeedback() function that accepts a bowling score 0 .. 300 and returns one of these messages:

    300: "most triumphant!"
    200..299: "pretty good!"
    50..199: "making progress!"
    0..49: "better take up Scrabble!"

    Examples

    bowlingScoreFeedback(250) => pretty good!


    bowlingScoreFeedback(25) => better take up Scrabble!

    _________________________________

    (3) Suppose you want to get a table at a hip restaurant: The variable "style" represents the stylishness of your clothes and "bribe" represents the bribe presented to the Maitre'd.

    The Maitre'd is satisfied if style is 8 or more and bribe is 5 or more.

    One way to code this up is to write the "satisfied" expression as a straight translation of the problem statement, and then put a ! in front of it:
    //Say something mean if not satisfied
    function maitreD(style, bribe){
    if (! ((style >= 8) && (bribe >= 5)) ) {
    return "tant pis pour vous"
    else
    return "Ainsi, s'il vous plaƮt"
    }

Wednesday, November 10, 2010

Google's Book Search: A Disaster for Scholars

Google's book search is clearly on track to becoming the world's largest digital library. Will it support scholarly research as well as bricks-and-mortar libraries? Metadata will be the deciding factor.



Google's Book Search: A Disaster for Scholars, by G. Nunberg.