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
// Arrays | |
// datatypeofarray arrayname[numberofitems]; | |
int Numbers[7]; | |
// in this array we have the following elements | |
int Numbers[7]; | |
- Numbers[0] | |
- Numbers[1] | |
- Numbers[2] |
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
// basic pointers demo | |
int data = 20; // actual variable declaration. | |
int *ip; // pointer variable | |
ip = &var; // store address of data in pointer variable | |
// prints an address | |
cout << "Address stored in ip variable: "; | |
cout << ip << endl; // prints out 8e34xA345te (An address) |
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 examples | |
// author : Tevin Thuku | |
// Date: 3rd: Dec: 2016 | |
class Square { | |
public: | |
double length; | |
double width; | |
}; |
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
// BASIC EXAMPLE OF NEW KEYWORD IN ACTION | |
Cars *benz = new Cars(); | |
// the delete keyword can be placed in the destructor | |
delete benz; | |
// EXAMPLE 2; |
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
/* Make clicks pass-through */ | |
#nprogress { | |
pointer-events: none; | |
} | |
#nprogress .bar { | |
background: #29d; | |
position: fixed; | |
z-index: 1031; |
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
//Single Queue simulation | |
#include <iostream> | |
#include <fstream> | |
#include <stdlib.h> //contains the rand() function | |
#include <math.h> | |
#include <iomanip> | |
#include <ctime> | |
#include <cstdlib> | |
using namespace std; |
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
let simpson n = | |
let f x = (3.0 /. 2.0) *. sin x *. sin x *. sin x in | |
let pi = (float_of_int 22 /. float_of_int 7) in | |
let h = pi /. float_of_int n in | |
let rec fstSum idx n acc = | |
if idx > n then (acc) else | |
fstSum (idx+1) n (acc +. f (float_of_int ((2 * idx) -1) *. h)) in | |
let rec sndSum idx n acc = | |
if idx > n then (acc) else | |
sndSum (idx+1) n (acc +. f (float_of_int (2 * idx) *. h)) in |
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
def unique_in_order(iterable): | |
listofargs = [x for x in (list(iterable))] | |
uniqueList = [] | |
prevItem = None | |
for item in listofargs: | |
if item == prevItem: | |
prevItem = item | |
continue | |
else: | |
uniqueList.append(item) |
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
def sum_two_smallest_numbers(numbers): | |
return sum(sorted(numbers)[:2]) |
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
import { Component, render } from "tevreact" | |
export default class App extends Component { | |
state = { | |
movie: "John Wick" | |
} | |
render() { | |
const { name } = this.state; |
OlderNewer