This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| norm_vec <- function(x) sqrt(sum(x^2)) | |
| x <- c(0.3, 0.4, 0.5, 0.6) | |
| c12 <- c(0.1, 0.1, 0.1, 0.1) | |
| c13 <- c(0.2, 0.2, 0.2, 0.2) | |
| w10 <- 0.1 | |
| w12 <- 0.2 | |
| w13 <- 0.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| cliente.cid AS cliente_cid, | |
| cliente.monto_sucursal_1 AS cliente_monto_sucursal_1, | |
| cliente.monto_sucursal_2 AS cliente_monto_sucursal_2, | |
| cliente.monto_sucursal_3 AS cliente_monto_sucursal_3, | |
| cliente.monto_sucursal_4 AS cliente_monto_sucursal_4, | |
| cliente.promociones AS cliente_promociones, | |
| cliente.dias_cliente AS cliente_dias_cliente, | |
| cliente.sucursales AS cliente_sucursales, | |
| cliente.promos_enviadas AS cliente_promos_enviadas, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| touch('/path/to/file.csv'); | |
| chmod('/path/to/file.csv', 0777); | |
| $spl = new \SplFileObject('/path/to/file.csv'); | |
| foreach ([ | |
| [1, 2, 3], | |
| [4, 5, 6], | |
| ] as $url) { | |
| $spl->fputcsv($url); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Conway's Game of Life | |
| * @see https://en.wikipedia.org/wiki/Conway's_Game_of_Life | |
| */ | |
| define('SIZE', 36); | |
| define('DISPLAY_ALIVE', '☼'); | |
| define('DISPLAY_DEAD', ' '); | |
| define('DISPLAY_NEWLINE', PHP_EOL); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| def bubblesort(input): | |
| swapped = True | |
| while swapped: | |
| swapped = False | |
| for i in xrange(0, len(input) - 1): | |
| if input[i] > input[i + 1]: | |
| swapped = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(howManyEqual). | |
| -export([howManyEqual/3]). | |
| rm_dup(List) -> | |
| lists:foldl( | |
| fun(Elem, Acc) -> | |
| case lists:member(Elem, Acc) of | |
| true -> | |
| Acc; | |
| false -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(maxThree). | |
| -export([maxThree/3]). | |
| maxThree(X, X, X) -> | |
| X; | |
| maxThree(X, X, Y) -> | |
| case max(X, Y) of | |
| X -> X; | |
| Y -> Y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % Fibonacci numbers | |
| % The Fibonacci sequence is given by 0, 1, 1, 2, 3, 5, … where subsequent values are given by adding the two previous values in the sequence. | |
| % | |
| % Give a recursive definition of the function fib/1 computing the Fibonacci numbers, and give a step-by-step evaluation of fib(4). | |
| % | |
| % Usage: | |
| % lists:map(fun(X) -> fibonacci:fib(X) end, lists:seq(0, 10)). | |
| -module(fibonacci). | |
| -export([fib/1]). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % Define a function pieces so that pieces(N) tells you the maximum number of pieces into which you can cut a piece of paper with N cuts. | |
| % You can see an illustration of this problem at the top of this step. | |
| % If you’d like to take this problem further, think about the 3-dimensional case. Into how many pieces can you cut a wooden block with N saw cuts? | |
| % Taking it even further: What is the general problem in n dimensions? | |
| -module(howManyPieces). | |
| -export([howManyPieces/1]). | |
| howManyPieces(0) -> | |
| 1; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.