Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
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
import java.io.IOException; | |
import org.jsoup.Jsoup; | |
import org.jsoup.nodes.Document; | |
import org.jsoup.nodes.Element; | |
public class App { | |
public static void main(String[] args) throws IOException { | |
Document doc = Jsoup.connect ("http://project2612.org/details.php?id=86").get(); | |
Element element = doc.select("td:containsOwn(English Title) + td").first(); | |
System.out.println("English name of the game: " + element.text()); |
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
body { | |
font-family: Helvetica, arial, sans-serif; | |
font-size: 14px; | |
line-height: 1.6; | |
padding-top: 10px; | |
padding-bottom: 10px; | |
background-color: white; | |
padding: 30px; } | |
body > *:first-child { |
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
using UnityEngine; | |
using UnityEngine.UI; | |
/* | |
Radial Layout Group by Just a Pixel (Danny Goodayle) - http://www.justapixel.co.uk | |
Copyright (c) 2015 | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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
using UnityEngine; | |
using UnityEngine.Networking; | |
using System.Collections; | |
using System.Collections.Generic; | |
using Zenject; | |
public class ZenjectNetworkManager : NetworkManager, IInitializable { | |
[Inject] | |
DiContainer Container; |
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
struct ApplyFnToParam<F> { | |
f: F, | |
param: u32 | |
} | |
fn my_default_fn(param: u32) -> bool { | |
param == 42 | |
} | |
// This is the part which blocked me the whole day, and I finally figured it out myself. |
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
#!/bin/bash | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
IFS=$'\n' | |
for f in $(find . -name '*.cs') | |
do | |
if ! grep -q Copyright "$f" | |
then | |
cat "$DIR"/copyright_header.txt "$f" >"$f".new && mv "$f".new "$f" |
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
/** | |
* Complexity O(log(k)) | |
*/ | |
private static String solve2(long n, long k) { | |
while (k != 1) { | |
n = ((n & 1) == 0 && (k & 1) == 1) ? (n / 2) - 1 : n / 2; | |
k = k / 2; | |
} | |
long bigHalf = n / 2; |
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
/** | |
* Complexity O(log(k)) | |
* Terminal recursion | |
*/ | |
private static String solve(long n, long k) { | |
if (k == 1) { | |
long bigHalf = n / 2; | |
long smallHalf = (n - 1) - bigHalf; | |
return "" + bigHalf + " " + smallHalf; |
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
(defn nth' [coll n] | |
(transduce (drop n) (completing #(reduced %2)) nil coll)) | |
(defn tree-seq' | |
[branch? children root] | |
(eduction (take-while some?) (map first) | |
(iterate (fn [[node pair]] | |
(when-some [[[node' & r] cont] (if (branch? node) | |
(if-some [cs (not-empty (children node))] | |
[cs pair] |
OlderNewer