memesearch
Функциональная очередь с двухсторонним доступом

Функциональная очередь с двухсторонним доступом

Download Find similar pictures
Text on the meme
1 type 'a deque = 2 | Empty 3 | Deque of 'a option * ('a * 'a) deque * 'a option 5 let rec push_front : type a . a -> a deque -> a deque = fun x deque -> 6 match deque with 7 | Empty -> Deque (Some x, Empty, None) 8 | Deque (left, child, right) -> 9 match left with 10 | None -> Deque (Some x, child, right) 11 | Some l -> Deque (None, push_front (x, l) child, right) 13 let rec pop_front : type a . a deque -> a option * a deque = function 14 | Empty -> (None, Empty) 15 | Deque (Some x, Empty, None) -> Some x, Empty 16 | Deque (Some x, child, right) -> Some x, Deque (None, child, right) 17 | Deque (None, Empty, right) -> right, Empty 18 | Deque (None, child, right) -> 19 let front, new_deque = pop_front child in 20 let first = Option.map fst front in 21 let second = Option.map snd front in 22 first, Deque (second, new_deque, right)
What it means

На изображении показан фрагмент кода на функциональном языке, реализующий двустороннюю очередь через рекурсивные типы и функции push_front и pop_front. Шутка основана на чрезмерно сложной и академичной реализации простой структуры данных — это реакция для программиста на избыточно усложнённое решение или функциональное программирование. EN: The image shows a functional-programming code fragment implementing a double-ended queue with recursive types and push_front and pop_front functions. The joke is the overly complex, academic implementation of a simple data structure, making it useful as a programmer reaction to overengineering or functional programming.

Objects
Tags
Source
Type
image
Size
800×613 · 79.7 KiB
Mood
абсурдный, саркастичный
Added