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
@Repository | |
public class AddressRepository { | |
List<Address> findAll() { | |
return List.of(new Address("a"), new Address("b")); | |
} | |
} | |
record Address(String street) {} |
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
function yahooJapan() { | |
for(let i = 0; i < 3; i++) { | |
console.log('request') | |
const request = require('sync-request'); | |
request('GET', 'https://www.yahoo.co.jp/', { | |
headers: { | |
'user-agent': 'example-user-agent', | |
}, | |
}); |
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
(ns clojure-tests.eight-queens) | |
(def empty-board '()) | |
(defn safe? [column positions] | |
(prn "positions: " positions) | |
(let [latest-row (first (first positions))] | |
(prn "latest-row: " latest-row) | |
(loop [pos (rest positions)] | |
(prn "pos: " pos) |
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
public class Main { | |
public static void main(String[] args) { | |
List<Integer> result = mymap(asList(1, 2, 3, 4, 5), | |
n -> n * n); | |
System.out.println(result); | |
} | |
static <T> List<T> mymap(List<T> list, Function<T, T> func) { |
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
public class Main { | |
static class Node { | |
final Object car; | |
final Node cdr = this; | |
Node(Object content) { | |
this.car = content; | |
} |
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
from typing import Optional | |
from fastapi import FastAPI | |
from pydantic import BaseModel, validator | |
class Item(BaseModel): | |
name: str | |
description: Optional[str] = None | |
price: float |
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
# example from: https://hypothesis.readthedocs.io/en/latest/examples.html | |
class Node: | |
def __init__(self, label, value): | |
self.label = label | |
self.value = tuple(value) | |
def __repr__(self): | |
return f"Node({self.label}, {self.value})" | |
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 abs [x] | |
(if (> x 0) x (* -1 x))) | |
(defn gcd | |
[a b] | |
(if (= b 0) | |
(abs a) | |
(recur b (mod a b)))) | |
(s/def ::gcd-args (s/cat :a int? :b 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
#include <assert.h> | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
int ack_recursive(int m, int n) { | |
if (m == 0) { | |
return n + 1; | |
} |
NewerOlder