All Questions
Tagged with functional-programming javascript
37
questions with no upvoted or accepted answers
4
votes
0answers
93 views
This recursive function encrypts a string
Is there a way to rewrite these last 2 recursive functions with fewer arguments (preferably 2) while keeping them recursive?
The entire code can be seen here: https://github.com/GirkovArpa/hutton-...
4
votes
0answers
172 views
Extensible factory method for starting D3 charts
I'm working on refactoring some existing code to be a bit more extensible and am wanting to create a generic factory API for starting D3 charts.
Currently, my factory looks like this:
...
3
votes
0answers
103 views
Functional Programming approach to a REST API example
I would like to know if there are any things I could improve with the following code regarding writing it in a FP style:
server.js:
...
3
votes
0answers
26 views
How would you convert this code to best take advantage of CSS transform for panning/zooming?
I am using react-flow-chart for a job project, but it doesn't implement zoom, and I would like to take the reigns and try applying it myself. I took a linear ...
3
votes
0answers
225 views
Refactored calls to an api using Ramda.js
This is the original code for accessing a service endpoint that returns information about a product. The exported methods of this module each take a single param of "id" and returns a Promise.
I've ...
3
votes
0answers
101 views
Advent of Code 2017 Day 3 (part 1) in Functional Programming (FP)
I wanted to practice functional programming (FP) without using any library but using vanilla JS only. So I took a problem from Advent of Code.
https://adventofcode.com/2017/day/3
You come across ...
3
votes
0answers
34 views
Test Driven Development in JS and Sinon Stub
I am going through some TDD and BDD tutorials which guide one through implementing a simple beverage-ordering system. While I think I understand the material, I am still wondering about some ...
3
votes
0answers
366 views
Two reimplementations of the Underscore _.reduce function
I am working on rewriting the underlying code for some Underscore.js functions. Re-writing the reduce function has been causing a lot of headaches. I have been able to re-write it two different ways, ...
3
votes
0answers
88 views
OAuth 1.0 signature using Ramda
I created an OAuth 1.0 signature generator using Ramda based on this.
I'm just getting to grips with it, so was wondering if someone more familiar with Ramda and functional programming would give me ...
3
votes
0answers
82 views
Calculating a snowballing investment
I'm currently taking a JavaScript class. I'm fairly familiar with JavaScript and coding in general, so I decided to teach myself functional programming on the side. It's been great, my teacher's fine ...
2
votes
0answers
29 views
Testing a javascript function that performs side effects
Application context
I am working on a game I call "Apes and Snakes". So far the code only allows players to connect to a host using a room code and WebRTC. Players and the host send messages ...
2
votes
0answers
30 views
Decoding request object before use it in an Insert query
I want to decode a request object before use it in an insert query.
Request object containes the following JSON body:
...
2
votes
0answers
99 views
Kaleidoscope Effect App
I've written a simple app that draws with a kaleidoscope effect in javascript, could someone please review the code? I'm especially interested in functional practices and design patterns.
...
2
votes
0answers
600 views
Determine whether there exists a one-to-one character mapping from one string to another
The task
Determine whether there exists a one-to-one character mapping from one
string s1 to another s2.
For example, given s1 = abc and s2 = bcd, return true since we can map
a to b, b to ...
2
votes
0answers
233 views
Sort a list using a reverse helper function
The task:
Given a list, sort it using this method: reverse(lst, i, j), which
reverses lst from ...
2
votes
0answers
50 views
Sort ascending/descending functionally
I've been trying to get into functional programming with javascript and have tried to make some experiments with currying and function composition.
What I've played with so far is a sorter function ...
2
votes
0answers
34 views
Javascript RPC Call Handles Data and Returns DB Response
I have a service within a larger set of microservices that's handling a RPC call. My function mainly just parses through the request, uses the data to insert data into our MongoDB database, and then ...
2
votes
0answers
102 views
Deep filter value using functional programming principles
deepFilter function uses a predicate to filter properties which may be nested deeply in the given ...
2
votes
0answers
135 views
Advent of Code 2017 Day 6 (part 2) in Functional Programming (FP)
I wanted to practice functional programming (FP) without using any library but using vanilla JS only. So I took a problem from Advent of Code (the 2nd part of Day 6).
You can only access the 2nd part ...
2
votes
0answers
96 views
React - Higher Order Component
My first go at a Higher Order Component in react.
Aims to give a component the ability to call an url repeatedly with a given refresh interval.
Seems to be working as I want. I'm not 100% confident ...
2
votes
0answers
97 views
Set manipulation (javascript arrays) using lodash
I'd like a more elegant and readable (if possible using functional programming style) for collection filtering (groupToAdd and groupToDelete collection handling)
Just getting rid of multiple _....
2
votes
0answers
978 views
D3.js multi-line graph
Here is my JS code which uses the D3.js library (mostly snipped from other examples). I want to graph the acceleration of a point in 3D-space which changes with respect to time. The X-axis of the ...
2
votes
0answers
92 views
Extracting data for a tag cloud using Lazy.js
I've just started using Lazy.js, which is my first exposure to a "functional style" javascript library. I'm still utterly lost as to which of the hundred different functional javascript libraries to ...
1
vote
0answers
43 views
Adding common Python functions to JavaScript
I have written a few classical Python functions in JavaScript. I would appreciate any kind of feedback. The main goal is to learn about JavaScript. For example errors, improvements or existing ...
1
vote
0answers
97 views
Transform vcards into contacts using functional programming in JavaScript
Context:
I'm building a React app using Ramda as a helper library for functional programming.
Users can import contacts into the app. These contacts can be vCards.
I've written a function that:
...
1
vote
0answers
150 views
Rotate a list by k elements
The task:
Write a function that rotates a list by k elements. For example, [1,
2, 3, 4, 5, 6] rotated by two becomes [3, 4, 5, 6, 1, 2]. Try solving
this without creating a copy of the list. ...
1
vote
0answers
58 views
Find the square root of n
The task:
Given a real number n, find the square root of n. For example, given n
= 9, return 3.
My solution:
...
1
vote
0answers
53 views
Custom indexeddb modules while trying to maintain the functional paradigm as much as possible
I'm a Web Development student, and I just started learning indexeddb a little while ago. At present my teacher hasn't taught us Promises, and I'm not really sure he plans to. So, I took the initiative ...
1
vote
0answers
117 views
Folktale 2 skeleton workflow for resetting a forgotten password
I am learning more about functional programming via loop recur's online book Mostly Adequate Guide to Functional Programming, and Brian Londorf's video series on egg head.
I started using ...
1
vote
0answers
402 views
Fetching weather data from API
I was experimenting with some code to fetch the current weather data as well as getting the hourly forecast. I could have done ...
1
vote
0answers
88 views
String and Date manipulation exercise using functional programming style
I was reading a question on stackoverflow recently and I became a little curious/interested in the philosophy behind Ramda (functional programming for Javascript). So I thought I would try an exercise....
1
vote
0answers
94 views
Using interface for generated functions or just create plain functions
I was wondering which code might be better. I'm abstracting away the rote code as follows:
...
1
vote
0answers
188 views
Remove items, resize columns, shuffle a list
I'm at the very beginning of starting to learn object-oriented programming patterns in JavaScript and PHP. Up until now I've always coded in a purely functional pattern. I'm doing a lot of reading, ...
0
votes
0answers
88 views
Create a template literal tag to remove whitespace from a string
I'm just getting into functional programming (as in, just started reading the book) and as practice I'm trying to refactor a past answer I wrote to fit in line with the functional style.
The ...
0
votes
0answers
68 views
Advent of Code 2017 Day 5 (part 2) in Functional Programming (FP)
I wanted to practice functional programming (fp) without using any library but using vanilla JS only. So I took a problem from Advent of Code (the 2nd part of Day 5):
https://adventofcode.com/2017/...
-1
votes
0answers
27 views
-1
votes
0answers
44 views
What would adding a state accumulator to my simple framework solve/add?
I've created a simple node modules that allows displaying a matrix of characters in the terminal, as well as capturing keypresses.
The purpose of the tool is to make simple games like snake, space ...