mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
This was done by first checking all files in the repository root by hand, and
then by doing the following:
$ npm i get-stdin@4
$ cat clean.coffee
fs = require 'fs'
stdin = require 'get-stdin'
stdin (text) ->
for file in text.trim().split('\n')
contents = fs.readFileSync file
.toString().replace /\s*$/, '\n'
fs.writeFileSync file, contents
return
$ ls !(node_modules)/**/*.coffee | coffee clean.coffee
12 lines
385 B
CoffeeScript
12 lines
385 B
CoffeeScript
# A bubble sort implementation, sorting the given array in-place.
|
|
bubble_sort = (list) ->
|
|
for i in [0...list.length]
|
|
for j in [0...list.length - i] when list[j] > list[j + 1]
|
|
[list[j], list[j+1]] = [list[j + 1], list[j]]
|
|
list
|
|
|
|
|
|
# Test the function.
|
|
console.log bubble_sort([3, 2, 1]).join(' ') is '1 2 3'
|
|
console.log bubble_sort([9, 2, 7, 0, 1]).join(' ') is '0 1 2 7 9'
|