Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
45 views

I have created a front-end for my language. I have also been able to transpile to C so that it can be compiled. In this language, functions are treated as first-class objects. Is it possible to ...
jinTgreater's user avatar
2 votes
2 answers
71 views

I observed a difference in output when trying to run similar function. function func1(){ function sum(){ console.log(2+5); } return sum(); } func1(); function func2(){ ...
SHAILY's user avatar
  • 51
-1 votes
2 answers
2k views

What are first class functions and first order functions? Are both are same or not? Are there any similarities/difference between first order and first class functions in JavaScript? I tried to get an ...
Jackson's user avatar
  • 17
0 votes
1 answer
29 views

I am learning Javascript and I came across these concepts of function expressions & first class functions. While I do understand their definition, I am unable to understand why my code behaves the ...
M Navneet Krishna's user avatar
5 votes
2 answers
195 views

Passing a function template as argument to another function template is always a bit tricky. Typically one has to resort to creating a lambda object that goes and calls the original function. Example ...
bitmask's user avatar
  • 35.2k
0 votes
2 answers
53 views

For example let's take the function add. I want to be able to call: add(1, 2)(3, 4) and add(1, 2) using same implementation. I have tried writing the add function the following way: var add = (a, b) ...
Ahmad Wehbe's user avatar
1 vote
1 answer
132 views

Section §2.1.3 at page 90 explains, with a very clear example, that first class functions in a language make functions themselves and data be the same thing looked at from different perspectives, or, ...
Enlico's user avatar
  • 30.2k
0 votes
1 answer
142 views

I am trying to create a infix notation as a extension function of (Int) -> Int function which is used to nest a function to another. For example: class Entry { companion object { ...
Langua's user avatar
  • 3
4 votes
3 answers
440 views

Structure and Interpretation of Computer Programs gives the following as the conditions that an element of a programming language must satisfy to be considered first-class: They may be named by ...
J. Mini's user avatar
  • 1,746
1 vote
1 answer
2k views

def some_function(): print("This will always be the same") def some_other_function(text): print(text) some_variable = "hello" list_of_elements = [ "element_one&...
CyberGeneticist's user avatar
-1 votes
2 answers
601 views

I have a simple promise, but I wonder why in my catch method I only need to pass "console.log" and it will automatically log that error if it happens? Does it have something to do with the ...
arthasnp98's user avatar
0 votes
3 answers
51 views

The code I have provided executes properly, however as you will see it offers refreshments to each guest repeatedly before moving on to the next guest. I'm scratching my head as to how I can alter my ...
Lil' Big Boy's user avatar
0 votes
1 answer
61 views

I have an existing dictionary and I want to add new element as a first-class function generated from a list. Is there a more pythonic way of doing this? agg_dict = {} for x in attribute_list: ...
little_stone_05's user avatar
1 vote
2 answers
2k views

Are there any differences between first class functions and callback functions in javascript? I thought that first class functions were functions that were treated as regular variables and can be ...
I_keep_getting_downvoted's user avatar
0 votes
0 answers
130 views

Note: This concept is touched upon in Lambda function in list comprehensions, but not to a sufficient depth for my understanding. We start with an example (in Python) of a closure: def ...
Jon Middleton's user avatar
0 votes
3 answers
313 views

I'm learning the concepts of first class functions and closures in Python and I was curious to know: Given a higher-order function: def html_tag(tag): def wrap_text(text): print("<{0}&...
Dave Kalu's user avatar
  • 1,605
1 vote
1 answer
142 views

enum SolarSystemPlanet: String, CaseIterable { case mercury, venus, earth, mars, jupiter, saturn, uranus, neptune func toRawValue(_ value: SolarSystemPlanet) -> PlanetName { value....
Tanin's user avatar
  • 595
0 votes
4 answers
1k views

Question as below: create a sum function, and the requirement: sum(1,2).result === 3 sum(1,2)(3).result == 6 sum(1,2)(3,4).result == 10 sum(1,2)(3,4)(5).result == 15 This is a question about ...
Wayne Ho's user avatar
0 votes
1 answer
249 views

The minimal code: twice :: (a -> a) -> a -> a twice f = f . f main = do return twice ++ "H" The errors generated: stack runhaskell "c:\Users\FruitfulApproach\Desktop\Haskell\test.hs" C:...
Luna's Chalkboard's user avatar
0 votes
4 answers
81 views

I do not understand how the parameter of the first class function, "number", has the value it does. I have been mulling over this problem for a couple of days and I am not making any progress in my ...
sector7g's user avatar
0 votes
1 answer
108 views

I am reading a book Mostly adequate guide and in the chapter about First Class functions, I have come across this example. Can somebody explain it to me? It says the below two lines are equal. // ...
Nida Munir's user avatar
5 votes
2 answers
862 views

Does the fact that this doesn't compile mean that they're not quite first class types? fun foo(s: String): Int = s.length // This won't compile. val bar = foo Is there a way to do this without ...
F. P. Freely's user avatar
  • 1,166
0 votes
0 answers
58 views

I'm working with a Set of CarCagetory: public struct Images { static let categoryTeaser = UIImage() } public enum PremiumModel { case model1, model2, model3, unknown } public struct ...
gmoraleda's user avatar
  • 2,003
1 vote
1 answer
712 views

I would like to create an array of member functions as a class variable so I can switch throughout the class etc. The following doesn't work class A: def b(self): pass def c(self): ...
Daniil Lantukhov's user avatar
1 vote
0 answers
67 views

I have a bunch of similar functions, which all have the same parameters. Some of the parameters have a default value. Here are two of them: func debug(_ message: String, eventid: String = Foundation....
Josef Zoller's user avatar