disabled 5ˆl–Ðz¾”ÂXÔÊ�fàpS�ÿ�þDä«7+b M§?à 623ÂÁÀo# Connect to this using websockets on port 9454 # Client sends to server in the format of {"data":[1,2,3]} # The websocket server returns the standard deviation of the sent array library(jsonlite) library(httpuv) # Server app <- list( onWSOpen = function(ws) { ws$onMessage(function(binary, message) { # Decodes message from client message <- fromJSON(message) # Sends message to client ws$send( # JSON encode the message toJSON( # Returns standard deviation for message sd(message$data) ) ) }) } ) runServer("0.0.0.0", 9454, app, 250) ˆ¿‘äÇò 8àJœ}’>6¿ŸÃ ƒh¹ÂÁÀdisabled 5 ˆl–ß=¿JÕ4Ÿº‚„ ƒp Ü ªbÑ¿�þDØÄ³e’0J&E$�ùÄ ƒ}ÆZÃÂÁ%¢ --- @class Ring --- Interface for an element of a ring with unity. Ring = {} __Ring = {} -------------------------- -- Static functionality -- -------------------------- --- Determines which ring the output of a binary operation with inputs in ring1 and ring2 should be, if such a ring exists. --- If one of the rings is a subring of another ring, the result should be one of the two rings. --- @param ring1 RingIdentifier --- @param ring2 RingIdentifier --- @return RingIdentifier function Ring.resultantring(ring1, ring2) if ring1 == ring2 then return ring1 end if ((ring1 == PolynomialRing.getring() and ring2 == Rational.getring()) or (ring2 == PolynomialRing.getring() and ring1 == Rational.getring())) and ring1.symbol == ring2.symbol then return Rational.makering(ring1.symbol, Ring.resultantring(ring1.child, ring2.child)) end if ring1 == PolynomialRing.getring() or ring2 == PolynomialRing.getring() then if ring1 == ring2.child then return ring2 end if ring2 == ring1.child then return ring1 end if ring1 == PolynomialRing.getring() and ring2 == PolynomialRing.getring() and ring1.symbol == ring2.symbol then return PolynomialRing.makering(ring1.symbol, Ring.resultantring(ring1.child, ring2.child)) end -- If none of the above conditions are satisfied, recusion is a pain, so we just strip all of the variables off of both rings. -- TODO: Make this properly recursive, or just use a multivariable polynomial ring class local symbols = {} while ring1 == PolynomialRing.getring() do symbols[#symbols+1] = ring1.symbol ring1 = ring1.child end while ring2 == PolynomialRing.getring() do if not Contains(symbols, ring2.symbol) then symbols[#symbols+1] = ring2.symbol end ring2 = ring2.child end local ring = Ring.resultantring(ring1, ring2) if ring == Rational.getring() and Contains(symbols, ring.symbol) then symbols = Remove(symbols, ring.symbol) end for i = #symbols, 1, -1 do ring = PolynomialRing.makering(symbols[i], ring) end return ring end if ring1 == Integer.getring() then if ring2 == Integer.getring() then return ring2 end if ring2 == Rational.getring() then return ring2 end if ring2 == IntegerModN.getring() then return ring2 end end if ring1 == Rational.getring() then if ring2 == Integer.getring() then return ring1 end if ring2 == Rational.getring() then if not ring1.symbol then return Rational.makering(ring2.symbol, Ring.resultantring(ring1, ring2.child)) end if not ring2.symbol then return Rational.makering(ring1.symbol, Ring.resultantring(ring1.child, ring2)) end if ring1.symbol and ring2.symbol and ring1.symbol == ring2.symbol then return Rational.makering(ring1.symbol, Ring.resultantring(ring1.child, ring2.child)) end