-
item 1
-
item 2
-
item 3
// code here
should be equivalent to...
- item 1
// source: http://java.dzone.com/articles/using-lambda-expression-sort | |
// sort by first name | |
people.sort((p1, p2) -> p1.firstName.compareTo(p2.firstName)); | |
// sort by full name | |
String fullName(Person p) { return p.firstName + " " + p.lastName; } | |
people.sort((p1, p2) -> fullName(p1).compareTo(fullName(p2))); |
/* | |
2D Angle Interpolation (shortest distance) | |
Parameters: | |
a0 = start angle | |
a1 = end angle | |
t = interpolation factor (0.0=start, 1.0=end) | |
Benefits: | |
1. Angles do NOT need to be normalized. |
/* | |
You can use this script with Google Swiffy to produce SVG frames from an SWF animation. | |
1. Upload your SWF file to Google Swiffy --> https://www.google.com/doubleclick/studio/swiffy/ | |
2. Save the swiffy output HTML page locally. | |
3. Edit the page to include this script with <script src="getSvgFrames.js"></script> | |
4. Open the page in Firefox to see the SVG download links appear for each frame. | |
*/ | |
(function(){ | |
var url = window.location.pathname; |
item 1
item 2
item 3
// code here
should be equivalent to...
entries = getListOfTableEntriesSomeWhere() | |
entryTree = MyTree(entries) | |
################################ | |
def group_entries(groupclass, entries, keyfunc): | |
return [groupclass(k,g) for k,g in itertools.groupby(entries,keyfunc)] | |
key_sys = lambda x: x.sys | |
key_subsys = lambda x: x.subsys |
% the tile width of the rectangular map | |
#const width=4. | |
positions(0..11). | |
rotations(0..3). | |
% piece(number, side, side type [g=grass, w=water, c=city, r=road]). | |
piece( 1,0,g ;; 1,1,g ;; 1,2,g ;; 1,3,w). | |
piece( 2,0,g ;; 2,1,g ;; 2,2,g ;; 2,3,w). | |
piece( 3,0,g ;; 3,1,w ;; 3,2,g ;; 3,3,w). |
def print_target_moves(aTimeCapacity, bTimeCapacity, targetTime): | |
''' | |
Given two hourglasses with respective time capacities, | |
print out a process for measuring the given target time | |
without going over that time. | |
An hour glass can only be flipped when any of them have run out. | |
TODO: generalize to multiple hour-glasses | |
''' | |
moves = [] |