This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaScript variables belong to one of the following scopes: global or local(function). | |
// Basically, any variable defined outside of a function is a global variable. Variables | |
// defined inside of a function are scoped narrowly to that function, and any other | |
// functions defined within the scope of that function (explicit use of the var keyword assumed). | |
var myName = "john"; | |
var capitalizeMyName = function() { | |
myName = myName.substring(0).toUpperCase() + myName.slice(1); | |
var name = myName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
; sq : number -> number | |
(define (sq num) (* num num)) | |
; f-to-c : number -> number | |
(define (f-to-c temp) (/ (- temp 32) 1.8)) | |
; how-cold : integer -> string | |
(define (how-cold temp) | |
(if (< (f-to-c temp) 0) "brrr" "could be worse")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ObjectOrientedPigLatinifier | |
def self.translate(string) | |
string.split(" ").map{ |word| new(word).translate }.join(" ") | |
end | |
def initialize(raw_word) | |
@raw_word = raw_word | |
@pig_latin_word = "" | |
@punctuation = "" | |
end |