Skip to content

Instantly share code, notes, and snippets.

@fevral13
fevral13 / cljcks.hiccup.clj
Created January 7, 2017 12:44
hiccup template engine naive implementation
(ns cljcks.hiccup
(:require [clojure.string :as s]))
(defn render-attr [[key value]] (str (name key) "=\"" value "\""))
(defn render-attrs [attrs]
(s/join " " (map render-attr (seq attrs))))
@fevral13
fevral13 / hiccup.py
Last active February 11, 2019 04:26
hiccup template engine naive Python implementation
class StringMeta(type):
def __getattr__(cls, name):
return name
class e(metaclass=StringMeta):
pass
def render_attrs(attrs):
@fevral13
fevral13 / comp.py
Last active November 13, 2017 12:53
Python implementation of LISP's comp function
from functools import reduce, partial
def comp(func1, *others):
"""
Inspired by Clojure function (comp)
Accepts positional arguments - functions
Creates functional composition of functions. Allows to pack nested functions call to single function:
result = f1(f2(f3(f4(args, kwargs))))