Exhibit A on the goodness of Javascript:
Module is-positive-integer
First implementation:
var passAll = require('101/pass-all')
var isPositive = require('is-positive')
var isInteger = require('is-integer')
let usedOnStart = 0; | |
let enabled = false; | |
let depth = 0; | |
declare var Source: any; | |
function setupProfiler() { | |
depth = 0; // reset depth, this needs to be done each tick. | |
Game.profiler = { | |
stream(duration, filter) { | |
setupMemory('stream', duration || 10, filter); | |
}, |
Exhibit A on the goodness of Javascript:
Module is-positive-integer
First implementation:
var passAll = require('101/pass-all')
var isPositive = require('is-positive')
var isInteger = require('is-integer')
******************** | |
* | |
***************** * | |
* * * | |
* ************* * * | |
* * * * * | |
* * ********* * * * | |
* * * * * * * | |
* * * ***** * * * * | |
* * * * * * * * * |
WebSocket.prototype._send = WebSocket.prototype.send; | |
WebSocket.prototype.send = function (data) { | |
this._send(data); | |
this.addEventListener('message', function (msg) { | |
if (msg.data.indexOf('console')>0) { | |
messages = (JSON.parse(JSON.parse(msg.data.substring(1))[0])[1]).messages.log; | |
for (msg in messages) { | |
console.log(messages[msg]); | |
} | |
}; |
{"ok":1,"data":"gz:H4sIAAAAAAAEA+1d227bSBL9Fz17ADab17zNZrVYYBEPkAx2sAjywJsc79pWVpZnEgT+9z3VF94pqtqUNME6L7HIJqtvdepUdXXz+2otwmvhr958X+222/vr7L5avbEXr1aPX7I/Ht5uHza3N1TkoXd7V/336XZX3VcPe7r9WO33d9Vu9ca7Wn3Odr9Xj3vzq9g+7W7N34/77S67qdYP1e7m21t7Q1yt8qfbu5IK4e9i+7Dfbe/wtnYJ8+hfbEHIuanwntuiLuU9U62rolOf76t3v/xzjReHV6vffnn/j9Ub/PH25/fv/4Vr9MTTl5tdpmR/NwWiuoB/ZZ6WKDhSL/vy5olIF3zc756K/e32oa6vfbm0r4xrKQGeqb7uq4dHPPBYN8e+PKkLJs/PKHp/+3D7cGNH5uN3c+FvdxkGavVO3f2qx/arWKnyqitpoFT3qvGAGLqAFpYYq/eYAJ3B1wNFPflV9903lFWNy4rPVV1HNLN6vjpYBX+uChjJF1fh09Xq7vbhP6s3H81fb3dV9UX/bMbt11328LihafZ9tc3/XRXogIenu7ur1T7b3VT49fET9TB1XkyFenoRoynTakF3T6QVGKWmFXXnYzD7WoFLy2gFJpnuJ609mOAD5UFHDXVHNKogMLD66QRF7aw1YGAnd1pP7hSFRhppC5L+WrUNddFpJUMljNZD3cxTce+huhuthG5VDihktyrHqiTppwgxRwqNe5BvFFD1tfmJAewpA02r4lilU0ICPNF7Z1fmEkIiNyHlbvvll82GlOu2BOKEYeXLKg1kGfpBGXhRVEWxiDd4OykflWtZHuqL+21JduqP7e6uxE+yATfffv49u73L8jvcCUSI4deX32ZfsuJ237ktPUL9L9tHejfAzUdpAjfg8UDdUfDz7R4lhYd/+se7jBBR/97+YbTk6bHamXpef84e/r5d4dF7vJYAktSUzMHTrvr12xeqvFFbVJ/+wpXvpsKoRxompArqhq2/Eahqz |
var http = require('http'); | |
var sockjs = require('sockjs-client'); | |
var request = require('request'); | |
var sock = new sockjs('https://screeps.com/socket'); | |
var user_id = ""; | |
var user_name = ""; | |
var password = ""; | |
var sleep = require('sleep'); | |
sock.onopen = function() { | |
console.log('open'); |
let map f m_in = | |
let m_out = Lwt_mvar.create_empty () in | |
let rec aux () = | |
Lwt_mvar.( | |
take m_in >>= | |
f >>= fun v -> | |
put m_out v >> | |
aux () | |
) | |
in |
Integer x, y, z; | |
x = y = 10; | |
z = 10; | |
System.out.println(x==y); | |
System.out.println(x==z); | |
x = y = 200; | |
z = 200; | |
System.out.println(x==y); | |
System.out.println(x==z); |
Mix.lock | |
%{"conform": {:hex, :conform, "0.13.0"}, | |
"cowboy": {:hex, :cowboy, "1.0.0"}, | |
"cowlib": {:hex, :cowlib, "1.0.1"}, | |
"decimal": {:hex, :decimal, "1.1.0"}, | |
"ecto": {:hex, :ecto, "0.8.1"}, | |
"exrm": {:hex, :exrm, "0.15.1"}, | |
"hackney": {:hex, :hackney, "1.0.6"}, |
(define (next-fibonaci x y) (stream-cons (+ x y) (next-fibonaci y (+ x y)))) | |
(define even-fibo (stream-filter even? (next-fibonaci 0 1))) | |
(define (take-while-helper s f result) | |
(if (f (stream-first s)) | |
result | |
(take-while-helper (stream-rest s) f (cons (stream-first s) result )))) | |
(define (more-than-4M x) ( > x 4000000)) | |
(apply + (take-while-helper (next-fibonaci 0 1) more-than-4M '())) |