first-class-functions Questions

6

Solved

The little knowledge I have about first-class functions is that it supports passing functions as arguments and we can also return them as the values in another function ... I am very new in Swift p...
V asked 7/10, 2014 at 12:40

7

Solved

Let's say I have a function def x(): print(20) Now I want to assign the function to a variable called y, so that if I use the y it calls the function x again. if i simply do the assignment y =...
Reflation asked 27/4, 2012 at 16:12

7

What is a first-class-citizen function? Does Java support first-class-citizen functions? As mentioned on Wikipedia: First-class functions are a necessity for the functional programming style. Is ...
Furring asked 3/3, 2011 at 8:0

8

I am still confused about what first-class functions are. If I understand correctly, first-class functions should use one function as an object. Is this correct? Is this a first-class function? def...
Augustin asked 10/12, 2014 at 2:31

6

Solved

I have this example code: class objectTest(): def __init__(self, a): self.value = a def get_value(self): return self.value a = objectTest(1) b = objectTest(1) print(a == b) print(a.get_valu...
Weightless asked 14/2, 2014 at 17:37

2

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 r...
Gandzha asked 25/2, 2019 at 17:4

1

Solved

i was going through a post post about how observer pattern can be implemented in python . on the same post there are these comments. 1) In python you may as well just use plain functions, the ‘O...
Zanthoxylum asked 12/6, 2017 at 12:27

3

Solved

In the Swift documentation Apple says this: Closures are self-contained blocks of functionality that can be passed around and used in your code. Closures in Swift are similar to blocks in C an...
Industrious asked 30/5, 2016 at 18:34

2

Solved

In C++, can I create an implementation of an interface on the fly (which ideally binds local-scope variables.) Not sure how to explain it better, so I will put down what I would like the code to lo...
Madder asked 24/5, 2016 at 16:50

5

I am solving a puzzle using python and depending on which puzzle I am solving I will have to use a special set of rules. How can I pass a function into another function in Python? Example d...
Mathematical asked 28/8, 2009 at 21:1

1

Solved

Suppose that we have several overloaded functions in one class: func appendToABC(string s: String) -> String { return "ABC \(s)" } func appendToABC(duplicatedString s: String) -> String { ...
Sven asked 8/1, 2016 at 13:17

2

Solved

I'm trying to dynamically call functions returning different types of struct. For example, let's take the following code. struct A { Name string Value int } struct B { Name1 string Name2 str...
Peridium asked 19/9, 2015 at 21:27

3

Solved

I am reading some books about the functional programming in swift. When I see some books said the function in swift is "first-class function" and I confused what is the meaning of the "first-class"...
Localism asked 13/3, 2015 at 0:47

7

This is a bit of an odd oop question. I want to create a set of objects (known at design time) that each have certain functions associated with them. I can either do this by giving my objects prope...

2

Solved

I've been successfully passing no-argument functions around in PowerShell using ScriptBlocks. However, I can't get this to work if the function has arguments. Is there a way to do this in PowerShel...

1

I understand the broad concept of a closure (functions are stored along with a snapshot of environment at the time they were defined), and functions as first class citizens means that functio...

4

Solved

In python, it's fairly straightforward to reference a function: >>> def foo(): ... print "foo called" ... return 1 ... >>> x = foo >>> foo() foo called 1 >>> x...
Sideways asked 27/11, 2010 at 23:27

1

i try to write an event handler in a scalaFx app. I found followin solution: import scalafx.scene.control.ListView import javafx.scene.input.MouseEvent import javafx.event.EventHandler ... val ...
Untune asked 17/2, 2014 at 17:59

4

Solved

Don't first class functions mean that they behave as variables? Clearly they don't behave exactly like variables though, since this: console.log(foo); var foo = 'bar'; ...doesn't work, whereas t...

1

Solved

Working on the following example in "Clojure in Action" (p. 63): (defn basic-item-total [price quantity] (* price quantity)) (defn with-line-item-conditions [f price quantity] {:pre [(> pr...

1

Solved

I have a function which takes a function and a number and returns the application of the function on the number, and a cube function: (defn something [fn x] (fn x)) (defn cube [x] (* x x x)) ...
Dulcet asked 20/4, 2011 at 6:26

2

Solved

More specifically what are the characteristics (if any) that delegates have that functions as first class values in F# don't have; and what are the characteristics that functions as first class val...
Germanize asked 9/10, 2010 at 19:24

2

Solved

I checked out the latest Ruby version, to play a bit with the latest changes. The first thing I tried to do was call a Ruby lambda/block/proc just like you'd do with a Python callable. a = lambda ...
Down asked 6/11, 2009 at 10:54
1

© 2022 - 2024 — McMap. All rights reserved.