목록2023/11/07 (2)
넘치게 채우기
여러 가지 의미로, 함수형 프로그래밍이라는 개념은 프로그래밍 그 자체보다 앞섰다. 이 패러다임에서 핵심이 되는 기반은 람다(lambda)계산법으로, 알론조 처지(Alonzo Church)가 1930년대에 발명했다. 정수를 제곱하기 25까지의 정수의 제곱을 출력하는 간단한 문제를 다뤄보자. 자바 언어라면 아래처럼 작성할 수 있다. public class Squint { public static void main(String args[]) { for(int i = 0; i < 25; i++) { System.out.println(i*i); } } 리스프에서 파생한 클로저(Clojure)는 함수형 언어로, 클로저를 이용하면 같은 프로그램을 다음과 같이 구현한다. (println (take 25(map (fn ..
https://leetcode.com/problems/eliminate-maximum-number-of-monsters/description/ Eliminate Maximum Number of Monsters - LeetCode Can you solve this real interview question? Eliminate Maximum Number of Monsters - You are playing a video game where you are defending your city from a group of n monsters. You are given a 0-indexed integer array dist of size n, where dist[i] is the initi leetcode.com ..