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
(defpackage 8-queens) | |
(defun copy-array (array) | |
(let ((dims (array-dimensions array))) | |
(adjust-array | |
(make-array dims :element-type | |
(array-element-type array) | |
:displaced-to array) | |
dims))) |
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
%% Los polinomios estan representados como lista de coeficientes | |
%% en la forma 1+2x+3x^2+4x^3 >> [1,2,3,4] | |
%% Suma de polinomios | |
%% (1+2x)+(3x+4x^2)=1+5x+4x^2 | |
%% suma([1,2],[0,3,4],S) >> S=[1,5,4] | |
suma([],[],[]). | |
suma([],YS,YS). | |
suma(XS,[],XS). | |
suma([XH|TX],[YH|TY],[S|TS]):- |
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
%% Carta mas alta=valor carta | |
%% Pareja=30 | |
%% Trio=60 | |
%% Doble pareja=90 | |
%% Full=120 | |
%% Color=150 | |
%% Poker=180 | |
%% Escalera color=210 | |
consecutivos([]). |
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 RomanCalculator (intToRoman,romanToInt) where | |
import Prelude hiding (floor) | |
import Control.Monad | |
type RomanNumber=String | |
arabics=[1,4,5,9,10,40,50,90,100,400,500,900,1000] | |
romans=["I","IV","V","IX","X","XL","L","XC","C","CD","D","CM","M"] | |
arabicsRomans :: [(Int,RomanNumber)] | |
arabicsRomans=zip arabics romans |
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
;; jneira's solution to http://4clojure.com/problem/53 | |
(fn sub [c] | |
(let [gt (comp last sort) | |
res (gt | |
(reduce | |
(fn [[x y] n] | |
(if (> n (last y)) | |
[x (conj y n)] | |
[(gt [x 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
;; jneira's solution to http://4clojure.com/problem/59 | |
(fn [& fs] (fn [& args] (for [f fs] (apply f args)))) |
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
;; jneira's solution to http://4clojure.com/problem/63 | |
(fn [f c] (reduce (fn [m n] (merge-with into m {(f n) [n]})) {} c)) |
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
;; jneira's solution to http://4clojure.com/problem/67 | |
(fn primes [n] | |
(letfn | |
[(next-prime | |
[prs nxt] | |
(if (empty? (filter #(= 0 (mod nxt %)) prs)) | |
(conj prs nxt) | |
(recur prs (inc nxt))))] | |
(->> (iterate |
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
;; jneira's solution to http://4clojure.com/problem/67 | |
(defn primes [n] | |
(let | |
[next-prime | |
(fn [prs] | |
(letfn | |
[(aux [[f & r :as c] nxt] | |
(cond | |
(empty? c) (conj prs nxt) | |
(zero? (mod nxt f)) (recur prs (inc nxt)) |
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
{-# LANGUAGE OverloadedStrings #-} | |
{- To Run: | |
Load in ghci | |
:set -XOverloadedStrings (for convenience) | |
Execute repl expr -} | |
import Control.Applicative | |
import Data.Attoparsec hiding (Result) | |
import Data.Attoparsec.Char8 (char8, isDigit_w8, isSpace_w8) |