Skip to content

Instantly share code, notes, and snippets.

@Repository
public class AddressRepository {
List<Address> findAll() {
return List.of(new Address("a"), new Address("b"));
}
}
record Address(String street) {}
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',
},
});
(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)
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) {
public class Main {
static class Node {
final Object car;
final Node cdr = this;
Node(Object content) {
this.car = content;
}
from typing import Optional
from fastapi import FastAPI
from pydantic import BaseModel, validator
class Item(BaseModel):
name: str
description: Optional[str] = None
price: float
# 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})"
(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?))
@lcs-felix
lcs-felix / ack.c
Created June 3, 2020 10:26 — forked from Sebbyastian/ack.c
Ackermann function in recursive and non-recursive form
#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;
}