This file contains 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
defmodule ToyRobot do | |
@directions [:north, :east, :south, :west] | |
@directions_to_the_right %{north: :east, east: :south, south: :west, west: :north} | |
@directions_to_the_left Enum.map(@directions_to_the_right, fn {from, to} -> {to, from} end) | |
@table_top_x 4 | |
@table_top_y 4 | |
def place do | |
{:ok, %ToyRobot.Position{}} |
This file contains 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
object QS { | |
def quickSort(xs: Array[Int]): Array[Int] = { | |
if (xs.length < 2) xs | |
else { | |
val pivot = xs(xs.length/2) | |
val less = xs.filter(n => n < pivot) | |
val greater = xs.filter(n => n > pivot) | |
quickSort(less) ++ Array(pivot) ++ quickSort(greater) | |
} | |
} |
This file contains 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
proc generateMap*(map: GameMap, maxRooms, roomMinSize, roomMaxSize: int, | |
mapWidth, mapHeight: int, player: Entity, | |
entities: seq[Entity], maxMonsterPerRoom: int): GameMap = | |
var | |
rooms: seq[Rect] = @[] | |
numRooms = 0 | |
result = map | |
randomize() |
This file contains 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
# A quick Nim translation of https://gist.github.com/munificent/b1bcd969063da3e6c298be070a22b604 | |
# With some help of the JS version | |
import random | |
const | |
HEIGHT = 40 | |
WIDTH = 80 | |
PLAYER = '@' | |
TREASURE = '$' |
This file contains 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
# A simple Bencode parser following Nim Days by xmonader | |
import strformat, tables, json, strutils, hashes | |
type | |
BencodeKind* = enum | |
btString, btInt, btList, btDict | |
BencodeType* = ref object | |
case kind*: BencodeKind | |
of BencodeKind.btString: s* : string | |
of BencodeKind.btInt: i* : int |
This file contains 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
let vao = block: | |
var res: GLuint | |
glGenVertextArrays(1, addr res) | |
res | |
glBindVertextArray(vao) |
This file contains 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
{ pkgs ? import <nixpkgs> {} }: | |
with pkgs; | |
let inputs = [ | |
gleam | |
erlang | |
rebar3 | |
]; |
This file contains 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
{ pkgs ? import <nixpkgs> {} }: | |
with pkgs; | |
let | |
erlang = erlangR23; | |
elixir = elixir_1_11; | |
nodejs = nodejs-14_x; | |
inputs = [ |
This file contains 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 | |
-- NVIM v0.5.0-dev | |
-- Build type: RelWithDebInfo | |
-- LuaJIT 2.1.0-beta3 | |
local execute = vim.api.nvim_command | |
local fn = vim.fn | |
local cmd = vim.cmd | |
local g = vim.g |
This file contains 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
local lspconfig = require'lspconfig' | |
local configs = require'lspconfig/configs' | |
local M = {} | |
M.setup = function() | |
-- Check if it's already defined for when reloading this file | |
if not lspconfig.ltex_ls then | |
configs.ltex_ls = { | |
default_config = { |