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
| function fib_recursive(n) { | |
| if (n <= 1) | |
| return n; | |
| return fib_recursive(n - 1) + fib_recursive(n - 2); | |
| } | |
| var fib = new Object(); | |
| fib.recursive = function(n) { | |
| if (n <= 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
| var minimum_number_of_stamps = function() { | |
| var memo = []; | |
| var min_stamps = function(postage, stamps) { | |
| if (postage == 0) { | |
| return 0; | |
| } else if (memo[postage]) { | |
| return memo[postage]; | |
| } else { | |
| var min = postage; | |
| for (i = 0; i < stamps.length; i++) { |
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
| var algo = { | |
| set_fib: function(fib) { this.fib = fib; }, | |
| call_fib: function(n) { | |
| return this.fib.recursive(n); | |
| } | |
| }; |
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
| var try_it = function(exception_logger) { | |
| try { | |
| fib_recursive(-1); | |
| } catch(e) { | |
| exception_logger.log(e.name, e.message); | |
| } | |
| } | |
| function fib_recursive(n) { | |
| if (n < 0) { |
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
| -- Map | |
| increment x = x + 1 | |
| map increment [1, 2, 3, 4] | |
| -- Map with curry | |
| map (+1) [1, 2, 3, 4] | |
| -- Map with lambda | |
| map (\x = x + 1) [1, 2, 3, 4] |
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
| increment [] = [] | |
| increment (x:xs) = if x < 3 then [] else (x+1):increment xs |
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 Board.Mark | |
| ( o | |
| , x | |
| ) where | |
| o = "O" | |
| x = "X" |
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 Main where | |
| import Board.Mark |
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 Main where | |
| import qualified Board.Mark |
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 Main where | |
| import Board.Mark hiding (x) | |
| x = 5 |
OlderNewer