Skip to main content

Questions tagged [closure]

A function (often anonymous) bound to the referencing environment in its original lexical scope in such a way that it will still have access to that environment (its variables and other references) if executed outside that scope.

5 votes
1 answer
95 views

I asked for feedback on part 1 of this Advent of Code challenge: Advent of Code 2015 "Not Quite Lisp", in Common Lisp I have read everyone's feedback and done a lot of further reading. I ...
Mountain Man's user avatar
1 vote
2 answers
209 views

Is there a better way to loop item of an array using forEach and make repeat it using setTimout/...
HackerMF's user avatar
  • 121
2 votes
0 answers
56 views

How can this code be improved by "closuring" of functions here? ...
maxiwer's user avatar
  • 21
2 votes
1 answer
589 views

I decided to write a simple tab bar for macOS using Swift. tabs.swift ...
shreyasm-dev's user avatar
4 votes
1 answer
265 views

For learning purposes, I have written a small calculator app on Python with tkinter. I want to check if my design uses best practices for OOP and seek advice on ...
Mattey's user avatar
  • 59
2 votes
0 answers
55 views

I wrote this code for finding, substituting and executing values in dictionary, much like $() bash operator works. I used nested functions for this, forming ...
nonForgivingJesus's user avatar
2 votes
0 answers
75 views

I made a closure-based PHP structure that behaves mostly like a classical object. To change the object's state, one must derive a new copy by passing the altered state to the ...
Benni's user avatar
  • 153
2 votes
1 answer
156 views

This question is to see if I can get some input on the "design pattern" I tried to implement here. I'm just learning about closure in JavaScript and I think I'm starting to get it. I'm wondering if ...
Anthony's user avatar
  • 191
5 votes
2 answers
1k views

I've been trying to learn Groovy lately and I tried to solve a problem which involves designing a routine that will calculate the average Product price per Group. I have the following data: ...
Marcelo Tataje's user avatar
7 votes
1 answer
2k views

This is for some quantum mechanics software so there will be references to molecules/atoms etc but the core issue is a python logging one, unrelated to all that. I have a couple of logging decorators,...
QuantumChris's user avatar
  • 1,405
3 votes
1 answer
409 views

The official Rust book chapter 13.1 includes an exercise to expand on the example provided in the chapter: Try modifying Cacher to hold a hash map rather than a single value. The keys of the hash map ...
qwerty's user avatar
  • 33
2 votes
1 answer
164 views

I have custom cell of tableview which is used as header as well as normal cell. In custom cell I have this properties ...
Prashant Tukadiya's user avatar
11 votes
2 answers
2k views

I have a Javascript function that calls my backend API using AJAX, let's say, updateDataUsingAjax. This is a resource intensive process, and I do not wish to allow ...
Nisarg Shah's user avatar
1 vote
2 answers
140 views

I wrote the following in Swift to perform a sum: let total:Double = session.courses.reduce(0) { $0 + $1.totalPrice() } It's concise, it does the job but it does ...
Arnaud's user avatar
  • 111

15 30 50 per page