Skip to content

Instantly share code, notes, and snippets.

View kristianpedersen's full-sized avatar

Kristian Pedersen kristianpedersen

View GitHub Profile
@kristianpedersen
kristianpedersen / propsWithSameNameAsValue.js
Last active November 11, 2020 21:48
If prop name and value are the same
// Boring :c
{songs.map(song => <LibrarySong setCurrentSong={setCurrentSong} song={song} />)}
// Fun and cool! :D
{songs.map(song => <LibrarySong {...{ setCurrentSong, song }} />)}
import './App.css'
import { useEffect, useState } from "react"
import axios from "axios"
// In package.json, add:
// "proxy": "http://api.wolframalpha.com/v2",
const BASE = "/query?input=pi&appid="
const APP_ID = "W766VX-QK99987KQ6"
const URL = BASE + APP_ID
@kristianpedersen
kristianpedersen / test.md
Last active September 6, 2021 19:18
JS works, Clojure logs empty list

Hi! Given a chess board position, I want to return all moves that have a distance of (x = 1 and y = 2) or (x = 2 and y = 1).

I have solved this in JavaScript, and I'm trying to implement it in Clojure, but my Clojure function just returns an empty list (). What am I missing?

Also, if you have any comments on readability or making the code more idiomatic, that's of course appreciated.

Here they are - first the JavaScript implementation, and then the Clojure one:

const originalBoard = [