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
// Create the context for user related data | |
export const UserContext = React.createContext(); | |
const user = { | |
name: 'Jean-Pierre', | |
sex: 'Yes' | |
} | |
// provider the user context anywhere in the app | |
function App() { |
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
; Now let’s formalize the process in terms of procedures. We start with a value for the radicand (the number whose square root we are trying to compute) and a value for the guess. If the guess is good enough for our purposes, we are done; if not, we must repeat the process with an improved guess. We write this basic strategy as a procedure: (define (improve guess x) (average guess (/ x guess))) (define (average x y) (/ (+ x y) 2)) (define (square x) (* x x)) (define (good-enough? guess x) (< (abs (- (square guess) x)) 0.001)) (define (sqrt-iter guess x) (if (good-enough? guess x) ; return guess guess ; otherwise (sqrt-iter (improve guess x) x ))) (define (sqrt x) (sqrt-iter 1.0 x)) (sqrt 9) |
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
function imageFit (img) { | |
$(img) | |
.attr('startwidth', $(img).width()) | |
.attr('startheight', $(img).height()); | |
//add 100% width to the container, so that the image stretches above its max width. | |
.parent().css('width','100%'); | |
//initial fit | |
fit(); | |
// Re-adjust when window width is changed |