Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
# load the package and data set "Teams" | |
install.packages("Lahman") | |
library("Lahman") | |
data(Teams) | |
# | |
# | |
# CREATE LEAGUE SUMMARY TABLES | |
# ============================ | |
# | |
# select a sub-set of teams from 1901 [the establishment of the American League] forward to 2012 |
// Here's my data model | |
function ViewModel() { | |
//this.firstName = ko.observable(first); | |
//this.lastName = ko.observable(last); | |
this.firstName = "first"; | |
/* | |
this.fullName = ko.computed(function() { | |
// Knockout tracks dependencies automatically. It knows that fullName depends on firstName and lastName, because these get called when evaluating fullName. | |
return this.firstName() + " " + this.lastName(); | |
}, this); |
// Here's my data model | |
function ViewModel(first, last) { | |
this.firstName = ko.observable(first); | |
this.lastName = ko.observable(last); | |
this.fullName = ko.computed(function() { | |
// Knockout tracks dependencies automatically. It knows that fullName depends on firstName and lastName, because these get called when evaluating fullName. | |
return this.firstName() + " " + this.lastName(); | |
}, this); | |
}; |
#include <iostream> | |
#include <algorithm> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
// The user would introduce different values for divisor | |
int divisor = 3; | |
vector<int> numbers { 1, 2, 3, 4, 5, 10, 15, 20, 25, 35, 45, 50 }; |
--- | |
name: ggplotly | |
layout: post | |
title: Make your ggplots shareable, collaborative, and with D3 | |
date: 2014-04-17 | |
author: Matt Sundquist | |
authorurl: https://plot.ly/team | |
tags: | |
- R | |
- API |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
// This code is based on matlab code provided through the course "Monte Carlo Methods in Finance". | |
// https://iversity.org/my/courses/monte-carlo-methods-in-finance/ | |
// and Olaf Smits's Python conversion | |
// http://nbviewer.ipython.org/github/olafSmits/MonteCarloMethodsInFinance/blob/master/Week%201.ipynb?create=1 | |
open System | |
open Deedle | |
open FSharp.Charting | |
let readFrame (stock:string) = |
#r @"\\psf\Home\Desktop\GitHub\eulersfsharp\src\Euler\bin\Debug\FSharp.Data.dll" | |
#r @"\\psf\Home\Desktop\GitHub\eulersfsharp\src\packages\MSDN.FSharpChart.dll.0.60\lib\MSDN.FSharpChart.dll" | |
#r "System.Windows.Forms.DataVisualization.dll" | |
open FSharp.Data | |
open MSDN.FSharp.Charting | |
open System.Windows.Forms | |
open System.Drawing | |
open System.Windows.Forms.DataVisualization.Charting |
#load @"..\packages\Deedle.0.9.12\Deedle.fsx" | |
#load @"..\packages\FSharp.Charting.0.90.5\FSharp.Charting.fsx" | |
// Please note that I had to use FSharp.Data.2.0.0-alpha as current stable version 1.1.10 | |
// has a bug in CSV provider that disallows to load from more than 2 sources in one execution | |
#r @"..\packages\FSharp.Data.2.0.0-alpha2\lib\net40\FSharp.Data.dll" | |
#r @"..\packages\MathNet.Numerics.FSharp.2.6.0\lib\net40\MathNet.Numerics.FSharp.dll" | |
#r @"..\packages\MathNet.Numerics.2.6.2\lib\net40\mathnet.numerics.dll" | |
open Deedle | |
open System |
// Homework 1 | |
// Color to Greyscale Conversion | |
//A common way to represent color images is known as RGBA - the color | |
//is specified by how much Red, Grean and Blue is in it. | |
//The 'A' stands for Alpha and is used for transparency, it will be | |
//ignored in this homework. | |
//Each channel Red, Blue, Green and Alpha is represented by one byte. | |
//Since we are using one byte for each color there are 256 different |