Click here to Skip to main content
15,891,657 members
Everything / Functional

Functional

functional

Great Reads

by JIANGWilliam
This is the first of three episodes to introduce considerations and techniques used for the throwable functional interfaces defined in my open-sourced library functionExtensions.
by D Sarthi Maheshwari
Discussing about streams... about streaming... about functional streaming... and nothing else.
by Bohdan Stupak
Way to leverage custom serializer in Giraffe framework
by Volodymyr Kopytin
In this article, we will see how to build a small application in a functional way.

Latest Articles

by Nicolas DESCARTES
How to embrace functional programming in C#
by Bohdan Stupak
Way to leverage custom serializer in Giraffe framework
by Volodymyr Kopytin
In this article, we will see how to build a small application in a functional way.
by BlackMATov
One of the currying options and partial application of the functions in C++ which is my personal favourite

All Articles

Sort by Score

Functional 

8 May 2018 by JIANGWilliam
This is the first of three episodes to introduce considerations and techniques used for the throwable functional interfaces defined in my open-sourced library functionExtensions.
27 Apr 2020 by Garth J Lancaster
I think you need to be really careful about the names of your functions vs what you're asking for - your question with 'append' string, yet you've named your function 'prependToString', and have 'appendToString in the console write - they are two...
6 May 2018 by Thomas Daniels
def prune(tree): result = [] for branch in tree: if branch != []: result.append(prune(branch)) return result You were almost there; the only step you missed, was adding the elements to a result list.
20 Dec 2018 by Rick York
Here's one way. Let's say your location of interest is at position (x,y). You can write a function (or method) called CheckTile and pass it the position to check. Then you can write your check logic something like this: CheckTile( x-1, y ); // to the left CheckTile( x, y-1 ); // the...
11 Mar 2019 by D Sarthi Maheshwari
Discussing about streams... about streaming... about functional streaming... and nothing else.
23 Dec 2021 by Bohdan Stupak
Way to leverage custom serializer in Giraffe framework
6 Nov 2018 by OriginalGriff
Using MAC addressed for security purposes is not a good idea: they aren't unique, just unique on a particular segment and are very easily spoofed. Plus, you aren't fetching the MAC address for the network adapter in that machine! See here: Retrieving IP and MAC addresses for a LAN[^] - there...
20 Nov 2018 by Richard MacCutchan
You need to convert the argument from two numbers to a single tuple, by adding an extra set of parentheses thus: print(position((2,2))) # ^ ^ # Extra parentheses make 2,2 into a single tuple.
23 Dec 2018 by OriginalGriff
The way I would do this is to cheat: My two board array would be bigger than the playing area. If you allow a border round the whole play area: 0 0 0 0 0 0 . . . 0 3 x 3 play area 0 . . . 0 0 . . . 0 0 0 0 0 0 So the array is [5,5] and the "actual play area" is just where the dots are:...
24 Jan 2020 by Richard MacCutchan
void djecja_reduta:: number_of_groups(){ karneval karneval; karneval.number_of_groups(); } This method creates a new karneval object, and then tries to output the total number of groups it contains. But this object does not contain any values for number_home_groups or ...
15 Apr 2021 by markkuk
According to the documentation[^] str.capitalize() does the following: Return a copy of the string with its first character capitalized and the rest lowercased. Your code line b=a.capitalize() undoes the changes done on the previous line.
13 Dec 2022 by CPallini
Quote: I want to write shorter condition than this Python y = (website[-4:]!=".com" and website[-4:]!=".net" and website[-4:]!=".org" and website[-4:]!=".gov" and website[-4:]!=".edu") y = not (website[-4:] in site)
18 Mar 2018 by Member 13730132
I am new to programming and java. I have created an application to open a file an display information about that . I want to split that file too. In function with RandomAccessFile there is some problem in the passed parameter. In function split() I want to use field fileName from function...
7 Apr 2018 by Member 13767746
Today i figured out how to make a function that reacts to a user input. But the problem I have is how to have a muti answer. (it's for a puzzle game.) #the functions over here #function end print("You wake up in a small room, a door in front of you.") print("A sofa behind you, and a desk...
7 Apr 2018 by Richard MacCutchan
See 4. More Control Flow Tools — Python 3.4.8 documentation[^].
24 Apr 2018 by souviksardar
I have one procedure in sql server like this::::: CREATE PROC SP_FetchData() as begin select FirstName, LastName from TBl_Users; select TaskId,CreatedBy from TBl_Log; END; I want execute the same query in postgres function without using refcursor. how can I do it? What I have tried: CREATE...
24 Apr 2018 by Wendelius
As far as I know PostGres does not support multiple result sets without cursors like SQL Server does. Basically you could join the result sets for example using UNION ALL operation but that would require that the structure and the data types of both results sets are the same. Based on your...
6 May 2018 by Member 13814092
I am trying to understand the details of this code do: prune = lambda tree : [prune(branch) for branch in tree if branch != []] l = [[[[], []], [[], []]], [[], [], []]] prune(l) But i have not yet learnt the lambda function. What I have tried: I am trying to break it down to the def...
26 Jun 2018 by Member 13887543
i have made a function and im adding 1 to the string im giving as input but function is not returning complete string ...... #include #include char *return_and_pass(char x[]) // OR char return_and_pass(char *s) { int i,carry; i=0; x[i]=x[i] + 1; ...
26 Jun 2018 by OriginalGriff
Look at your code. You add one to the FIRST character in the string: x[i]=x[i] + 1; So the string becomes "223". Then you work out your carry: carry=x[i]/10; which ... doesn't do what you think it does... x[i] is a char value, and contains '2' - that is not the same a the value 2, it's a...
26 Jun 2018 by Kornfeld Eliyahu Peter
You are working with string representation of 123, so you are actually working with the values 31, 32, 33 (ASCII (HEX) values of the char '1', '2', '3')... So no way you would get the 'right' value... Without understanding the reasons for such an obscure code... do this: 1. Reverse the string 2....
7 Aug 2018 by Member 13884629
Hello, needing some wordpress & woocommerce help here. In content-product.php , I’ve seen this code echo all product categories for each loop product.
22 Aug 2018 by Patrice T
Quote: SOMEONE PLEASE HELP ME SOLVE THIS?!?!?!?! The help you want is us doing your homeWork. You show no attempt to solve the problem yourself, you have no question, you just want us to do your HomeWork. HomeWork problems are simplified versions of the kind of problems you will have to solve...
22 Aug 2018 by Vincent Maverick Durano
READ: Programming Problems and Finding Solutions[^] PS: Adding those exclamation marks on the subject line suggests you are late with your homework, it's rude and no one is interested in that. If you want us to help you, then start doing something by yourself. Show us what you've tried and...
12 Oct 2018 by Member 13870077
So i have a list of list: [['Musique', 'Shawn Phillips', '2018-08-24', '2018-08-24'], ['Musique', "L'avenue Royale fête l'été!", '2018-08-25', '2018-08-25'], ['Musique', 'Perséides musicales', '2018-08-03', '2018-08-03'], ['Musique', 'Gaétan Leclerc chante Félix et…', '2018-08-17',...
12 Oct 2018 by Richard MacCutchan
for element in obtain_events: if '2018' in element: numbers = element.split('-') ... The variable numbers will be a list containing something like: [ '2018', '08', '24' ]. You can now do what you want with each field, if necessary converting them to...
13 Oct 2018 by Richard MacCutchan
I gave you the answer yesterday in your original question: How do I extract a part of a string in a list and change it into an int.[^]. Please do not repost the same question.
21 Oct 2018 by Member 13870077
There is a lot function involved but im gonna keep it simple : Here is my code : [['Musique', 'Initiation au tango argentin suivi de la milonga', 182, 231], ['Musique', 'The Singing Pianos', 216, 216], ['Musique', 'Rythmes et détente : Duo Pichenotte', 216, 216]] I want to return only the...
21 Oct 2018 by CPallini
What's wrong with events = [['Musique', 'Initiation au tango argentin suivi de la milonga', 182, 231], ['Musique', 'The Singing Pianos', 216, 216], ['Musique', 'Rythmes et détente : Duo Pichenotte', 216, 216]] for ev in events: print(ev[1]) ?
6 Nov 2018 by Jayanta Modak
show error for multiple set of MAC address i create a project here check the mac address process if match then run application else close the application but some time show 061EA6B401C8 this mac address some time D0BF9C07C7EA some time others please help me i have a idea MAC address is fix but...
20 Nov 2018 by Member 13870077
def position(position): position_piece = 2,2 x,y = position if (x,y) == position_piece: return position_piece else: return None print(position(2,2)) How can i put a tuple into a single argument like position? There has to be a way to do this without adding an...
17 Dec 2018 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
17 Dec 2018 by RickZeeland
See articles here: Interfaces in C# (For Beginners)[^] Explicit Interface VS Implicit Interface in C#?[^]
17 Dec 2018 by CPallini
Interfaces are valueable themselves (that is they are a neat concept in OOP programming). Then they are also the workaround to the lack of multiple inheritance of the C# programming language. You may easily find all the details in the documentation (and in good books).
20 Dec 2018 by average_angela
i'm trying write the code for a minesweeper game. trying to write a function in the c language to reveal the tiles around the selected tile if the selected tile has no bombs around it. i think this can be done recursively but got no clue about how to do it that way. the thing is i don't know if...
23 Dec 2018 by average_angela
hey, i am trying to write the code for a function to reveal the tiles with no bombs around them around the selected code. i have written the code that can reveal the bombs around one tile with the range of 1 and i can use this exact function for all the tiles around the selected one again but...
9 Feb 2019 by CPallini
Quote: print (word(- 100)) print (word(- 42)) print (word(13)) The above code is not part of the word function, it is in the global scope (it is NOT indented). If you define def main(): print (word(-100)) print(word(-42)) print(word(13)) then you have to call it in the global scope, in...
10 Mar 2019 by Member 14176249
Dear i need to get the kerberos mathematical function or algorithms for university project, if its possible to have me these function. thank you very much What I have tried: i had tried several web such as ieee but i did not find it there.
10 Mar 2019 by OriginalGriff
Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here... A very quick search using your subject as the search term gave over a quarter of a million hits: kerberos mathematical function or algorithms - Google Search[^] In future,...
5 Aug 2019 by Member 14549814
I want a vector of functions that would look something like this: vector>v; but obviously this didn't work... something like this: #include using namespace std; int f1(int n){ return n*2+2; } string f2(string n){ return n+'!'; } int main(){...
4 Aug 2019 by Rick York
Here's one way it can be done. typedef UINT( WINAPI * ThreadFunc )( PVOID ); typedef struct { ThreadFunc function; PVOID argument; } OneFunction; int main() { std::vector functions; OneFunction f; // set the members of f here ...
5 Aug 2019 by Stefan_Lang
Don't do this. It's probably doable with variadic templates, but judging by your code you already have enough trouble without templates. Moreover, putting functions (or rather references to functions) into a container eliminates readability, makes your code hard to read and prone to errors. ...
24 Jan 2020 by Member 14726049
I am trying to use int number_of_groups return and pass it into djecja_reduta function this is header file and then printing it for first karneval number_of_groups() gives out normal values but void djecja_reduta::number_of_groups() gives very crazy results and random numbers Example: I...
24 Jan 2020 by Patrice T
Quote: Passing values into another class function gives crazy values when printed Your code do not behave the way you expect, or you don't understand why ! There is an almost universal solution: Run your code on debugger step by step, inspect variables. The debugger is here to show you what...
25 Mar 2020 by Nyssa Ayu
Please help me to fix this Fatal error: Uncaught Error: Call to undefined function mysql_real_escape_string() in C:\xampp\htdocs\webdua\pusing\xxx\proses.php:7 Stack trace: #0 {main} thrown in C:\xampp\htdocs\webdua\pusing\xxx\proses.php on...
25 Mar 2020 by phil.o
Usemysqli_real_escape_string() instead. You should get used to do simple research like this one: simply typing the error (Call to undefined function mysql_real_escape_string()) in your favourite search engine would have brought you an immediate...
9 Aug 2020 by Volodymyr Kopytin
In this article, we will see how to build a small application in a functional way.
12 Aug 2020 by Dave Kreskowiak
Google for "replace a string resource in DLL" for options. Keep in mind that this is NOT AN ANSWER! This is POSSIBLE solutions that are not guaranteed to work with your .DLL. If you are modifying a DLL that is signed, your modifications will...
15 Sep 2020 by hmdismail
I wanted to design and implement a RateLimiter function, which allows the following usage: from my understanding, when somebody calls do, the RateLimiter needs to do one of two things with the passed-in lambda: -Start executing it...
15 Sep 2020 by Richard Deeming
Sounds like you need a Javascript semaphore. For example: GitHub - jsoendermann/semaphore-async-await: Promise based Semaphore suitable to be used with async/await.[^]
12 Jan 2021 by sk909923
from pyspark.sql import SparkSession from pyspark.sql.functions import * from pyspark.sql.types import * class streaming: def __init__(self, inputformat, input_json_schema): self.inputformat = inputformat, ...
12 Jan 2021 by thatraja
I don't know python. But withColumn is a function so you're missing something before that. Probably you need to query. before first withColumn. So make required changes. query = query.withColumn("contains_km",...
12 Jan 2021 by Richard MacCutchan
I guess you copied this code from somewhere. See Spark DataFrame withColumn — SparkByExamples[^].
26 Jan 2021 by Dr Doggo
I am trying to write a simple code to find the sum of all values within a given range in BST using recursion but for some reason, the 'summ' variable is not functioning the way I think it should work. Here is the code def rangeSumBST(self,...
26 Jan 2021 by OriginalGriff
Writing your code does not mean it is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email...
8 Feb 2021 by Member 15067760
const GooglePlacesInput = () => { const [city, setcity] = React.useState(''); useEffect(() => { console.log() }) const onRequestTagClick = async () => { const token = userSession.getAccessToken(); const requestData = { ...
15 Apr 2021 by Pooja Ekbote
Write a function that capitalizes the first and fourth letters of a name The output should be --> old_macdonald('macdonald') --> MacDonald def old_macdonald(name): a=name.capitalize() b=a[3].capitalize() c=a.replace(a[3],b,1) ...
15 Apr 2021 by CPallini
Because the second call to capitalize removes the effect of the first one def old_macdonald(name): a=name.replace(name[3],name[3].capitalize(),1) # this makes the fourth character uppercase b=a.capitalize() # this makes the first...
3 May 2021 by Member 13702159
hi, could you please explain the declaration below? I am trying to understand but this one is not intuitive to me. add :: Integer -> Integer -> Integer --function declaration add x y = x + y --function definition why...
3 May 2021 by CPallini
Here some insight: A Gentle Introduction to Haskell: Functions[^].
15 Aug 2021 by timothee chalamet
i came through a question which states that to define a function vowelEncryption which accepts an argument str representing a string value which contains only alphabets. . the function must encrypt the given string by replacing the...
15 Aug 2021 by Richard MacCutchan
You are only capturing single vowels. You need to use a flag to identify when the substring changes from vowel to consonant and vice versa. Something like: count=0 vowel = False for letter in sentence: if letter in vowels: ...
17 Aug 2021 by gabriel19971029
Hi! I'm writing a function that counts all even numbers of an array, and it works pretty well, but, I don't know how to avoid counting empty strings or empty arrays as O while counting the number 0 as even. Here is my code: function...
26 Aug 2021 by OriginalGriff
Read the question again: you have to display a message at regular intervals. So ... the first thing you will need is a loop of some form ... Read it carefully - it tells you exactly what to do, and the code you show doesn't fit it at all!
19 Oct 2021 by DerekT-P
I don't know about "best practice" in this use case; however - depending on the number of words involved - you may find the overheads of setting up many separate controls are excessive... if only in terms of page size. I'd probably approach...
5 Dec 2021 by MissMacDaddy
I need to create a program in Kotlin (or swift) with separate Value Returning Functions (dollars(), quarters(),dimes(),nickels(),pennies()) that counts how many dollars, quarters, dimes, nickels, and pennies are in my total. I have created the...
5 Dec 2021 by Richard MacCutchan
Here is a sample that may help. It is far from perfect but should give you an idea how to proceed. Ideally you would have another function that is called to do the printing, but you can leave that for the next assignment. fun main(args:...
13 Feb 2022 by OriginalGriff
This is the same question you asked yesterday: Python: I need to get my values to print using __str__ but I dont know how[^] And the solution is the same: read up on __str__ using the link you were given then, and think about what you are being...
15 Aug 2022 by Member 15737857
I am doing my project in ionic 6 with angular and a firebase database. I need a typescript function that adds the values fetched from an array that are extracted from a collection in firebase. async getGastos() { const uid = await...
4 Nov 2022 by Member 10604657
I have a function in SQL server and I used it in an application that I don't have access to its source file,so I cannot change the application. this function is likes below: create function f1(param1 int) Returns @rep Table (Id Int,T_Date...
4 Nov 2022 by Richard Deeming
You can't. Any query that selects from a table, view, or table-valued function without explicitly specifying an ORDER BY clause will receive the results without any particular order applied. There may be some cases where it seems like SQL...
13 Dec 2022 by Rama Aljelani
I want to write shorter condition than this y = (website[-4:]!=".com" and website[-4:]!=".net" and website[-4:]!=".org" and website[-4:]!=".gov" and website[-4:]!=".edu") What I have tried: website = str(input("Enter your URL: "))...
15 Dec 2022 by OriginalGriff
Quote: I want a better and easier code please. While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of...
16 Dec 2022 by Richard MacCutchan
How about this: vowels = 'aeiou' word = input('Enter your word: ') for x in range(len(word) - 1): if word[x] in vowels and word[x] == word[x + 1]: newword = word[:x] + word[x+1:] print(word,...
11 Jan 2023 by Reverend Jim
Not sure what should happen with more than two consecutive vowels but what about word = input('Enter your word: ') out = '' last = '.' vowels = 'aeiouyAEIOUY' for letter in word: if letter in vowels: if last not in vowels: ...
5 Nov 2018 by José Cintra
Calculating some mathematical sequences and series with the Haskell programming language
4 Nov 2019 by BlackMATov
One of the currying options and partial application of the functions in C++ which is my personal favourite
9 May 2018 by JIANGWilliam
This is the third of three episodes to introduce considerations and techniques applied in Repository classes in my open-sourced library functionExtensions.
17 Aug 2021 by Richard MacCutchan
I would suggest you go to JavaScript Tutorial[^] and work through the tutorials.
1 Feb 2024 by Nicolas DESCARTES
How to embrace functional programming in C#
13 May 2019 by Mahsa Hassankashi
Functional Programming Advantages
10 Jan 2021 by Keith.Badeau
I am looking for Scheme-oriented learning material geared towards experienced programmers. I already have some experience with Scheme and I would like to move to another level. What I have tried: I learned Scheme itself from multiple...
17 Aug 2021 by Richard Deeming
If you only needed to test for actual numbers, this would be simple. However, things are complicated by the fact that you want to treat a string containing the decimal representation of a number as the number it represents. I'd suggest creating...
12 Apr 2012 by Lakamraju Raghuram
Here are few of your statements1. "I am a programmer of sorts so I do not need tutorials or articles to explain *every* detail--only the language, not "programming" (unless it is a functional pattern, of course)"2. "I am looking for Articles, papers, tutorials"3. "I'm trying to learn...
31 Aug 2021 by Mehrez Kanzari
I'm trying to implement the monitor function in Python. This function must display at regular interval the date followed by the return of the "measure" function. It stops after `cycles` executions and the interval will never be less than 1. The...
22 Aug 2018 by Member 13958388
SOMEONE PLEASE HELP ME SOLVE THIS?!?!?!?! SelectKRandomPointsPurposeSelectKRandomPoints generates a list of k randomly selected pixelsfrom an image. Input(s):It takes twoinputs in the following order: 1)A 3D image array from which to select points from 2)The number of points to randomly...
3 Nov 2020 by Pseudocode01
Been bashing my head trying to solve this practice problem: Write a function called appendToString, which accepts two strings. The function should return a new string which consists of the second string appended to the first string. example:...
12 Aug 2020 by jack dannils
http://i.epvpimg.com/jSVEbab.p...
3 Nov 2020 by Member 14983381
Hey, the code below is a function that accepts two strings in JavaScript. let x = appendToString("Hello," , " World!"); // Hello, World! console.log(x); function appendToString(a, b) { return a + b; } //If you want to add more strings simply...
13 Oct 2018 by Member 13870077
Here's the return of my function: [['Musique', 'Shawn Phillips', '2018-08-24', '2018-08-24'], ['Musique', "L'avenue Royale fête l'été!", '2018-08-25', '2018-08-25'], ['Musique', 'Perséides musicales', '2018-08-03', '2018-08-03'] I have to use a loop to i can search all those index and...
17 Dec 2018 by ahmed_sa
I work on c# on visual studio 2015 i read and using interface class more public interface dataInterface { //prototype function here } and it have big role in solving multi inheritance on csharp so that What is the problems or disadvantages of using interface ? What I have tried: what is...
9 Feb 2019 by Member 14141186
I am using Python 3.7 and I have some questions about my code. what does "returning the string only" mean? If a function is just returning the string, how can I print that - returned string at the end of my code? For example, if I write the following code: def word(num): d1=...
19 Oct 2021 by Chana Gross
To display text where each word is selectable. Which Html element is recommended to surround each word. I would like it to be visible to the user and underline when selected. What I have tried: This doesn't didn't reference to my call of the C#...
9 Feb 2022 by Member 15530401
I have a neural network model (model.predict in code) which fitted our data, and now we want optimized some variables that exist in the model. my code are attached below, def objective_function(X): wob = X[0] torque= X[1] RPM = X[2] ...
13 Feb 2022 by LH Alpha
(please note I need to use two classes and the __init__ and __str__)I need to print out the values of my code using str but it's not printing out I am confused because I feel like I added all the attributes correctly and it gets all the values...