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
| aaa |
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
| aaa |
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
| aaa |
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
| ;; version 1 | |
| (def game {:world {:tiles 5}}) | |
| (defn get-tiles | |
| [{{:keys [tiles]} :world :as game}] | |
| (println game) | |
| (println tiles)) | |
| (get-tiles game) | |
| ;; version 2 | |
| (def game {:world {:tiles 5}}) | |
| (defn get-tiles |
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
| ;; Accessing / indexing 2d vectors in clojure | |
| (def tiles [[1 2 3] [4 5 6]]) | |
| (tiles 1) | |
| ((tiles 1) 2) |
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
| (defmulti process-input | |
| (fn [game input] | |
| (:kind (last (:uis game))))) | |
| (defmethod process-input :start [game input] | |
| (-> game | |
| (assoc :world (random-world)) | |
| (assoc :uis [(new UI :play)]))) |
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
| (defn print-row [row] | |
| (println (apply str (map :glyph row)))) | |
| (defn print-world [world] | |
| (dorun (map print-row (:tiles world)))) |
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
| (require '(clojure [string :as str] | |
| [walk :as walk])) | |
| (defmacro reverse-it | |
| [form] | |
| (walk/postwalk #(if (symbol? %) | |
| (symbol (str/reverse (name %)))) | |
| form)) | |
| (reverse-it | |
| (qesod [gra (egnar 5)] | |
| (nltnirp (cni gra)))) |
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
| (defmacro oops [arg] `(frontfdsa ~arg)) | |
| (macroexpand-1 `(oops 13)) | |
| (macroexpand-1 '(oops 13)) |
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
| package com.company; | |
| public class Main { | |
| public static void main(String[] args) { | |
| for(int i = args.length() - 1; i >= 0; i--) { | |
| reverse(args[i]); | |
| } | |
| System.out.println(); | |
| } |