Skip to content

Instantly share code, notes, and snippets.

-module(index).
-export([create/1]).
% Given a file name, returns the sorted index with
% entries that look like
%
% { "foo" , [{3,5},{7,7},{11,13}] }
%
-spec create(string()) -> [{string(), [{integer(), integer()}]}].
create(Name) ->
-module(index).
-export([
lines_from_contents/1,
get_file_contents/1,
show_file_contents/1,
basic_index_from_lines/1,
intermediate_index/1,
final_index/1]).
% C = index:get_file_contents("gettysburg-address.txt").
-module(index).
-export([
lines_from_contents/1,
get_file_contents/1,
show_file_contents/1,
basic_index_from_lines/1,
intermediate_index/1,
final_index/1]).
% C = index:get_file_contents("gettysburg-address.txt").
g/_/ s/./\l&/g | s/_\(.\)/\u\1/g
that depends on you use case, but a Map[Key, List[Value]] could work if you need key lookup
a more typesafe alternative would be a Map[Key, NonEmptyList[Value]], but you'd have to get the NonEmptyList from somewhere else
the simplest would be just something like a List[(Key, Value)]
you could also look in to a Vector[(Key, Value)] sorted by key so you can binary search on it and such
Options aplenty
npm install -g @angular/cli
ng help
ng new myboiler-prototype
cd myboiler-prototype
ng serve
ng serve --host 0.0.0.0 --port 4201
http://www.protractortest.org/#/
npm install -g --dev-save protractor
export class User {
constructor(
public id: string,
public name: string,
public username: string,
public email: string
) {}
}
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { User } from "app/models/user";
@Injectable()
export class UserService {
constructor(private http: Http) {
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { UserService } from "app/services/user.service";
@NgModule({
declarations: [
<div>
<ul>
<li *ngFor="let user of users | async">{{user.name}}</li>
</ul>
</div>