Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mohanr
mohanr / letter.ml
Last active December 6, 2016 07:26
Associative List
let insert l a =
if List.mem_assoc a l
then
let n = List.assoc a l in (a, n+1)::(List.remove_assoc a l)
else (a, 1)::l
let letters (word : string) : char MultiSet.t =
let rec insert (l : char MultiSet.t) (c : string) (i : int) : char MultiSet.t =
if ( String.length c > 1 ) then
insert ( MultiSet.insert l (String.get c i) ) ( String.sub c 1 ((String.length c) - 1) ) 0
@mohanr
mohanr / gist:9c79ed88b0e88a76b935
Created May 20, 2015 06:54
Add text boxes dynamically using AngularJS
<div ng-app="app" ng-controller="MainCtrl" ng-init="textboxes = ['Text1','Text2','Text3']">
<div ng-repeat="box in textboxes">
{{box}}
<copyoftextbox ng-model="models[$index]" name={{box}} index={{$index}}></copyoftextbox>
</div>
</div>
var app = angular.module("app", []);
app.controller('MainCtrl', function($scope) {
$scope.models = ['model1','model2','model3'];
@mohanr
mohanr / ReactiveCompletion.java
Created June 6, 2014 05:12
CompletableFuture example
import org.apache.http.HttpEntity;
import org.apache.http.client.fluent.Content;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;