:D

Is there a function that works like this:

`fn([add(1), add(10)], 1) // -> [2, 11]`

I know I can use

`ap`

if I wrap the second argument in an array, but I'm looking for a function that doesn't require the second argument to be contained in an array.
almost pipe

right?

I had been thinking I'd prefer a unary pipe anyway

`pipe ([ add(1), add(10) ]) (1)`

oh wait

nm

you want an array result

This does the trick:

```
map ( applyTo ( 1 ) )
([add ( 1 ), add ( 10 ) ])
// -> [2, 11]
```

For clarification, this is what I'd like to have:

`const fn = fns => x => map ( applyTo ( x ) ) ( fns )`

Easy to write on my own, but I'd prefer to use an existing function if there is one. Also, if I need to write it myself, I'd love some tips for what to name it :)

Hi

Hey :wave:

@m59peacemaker: We know the *natural*, counting numbers like `1, 2, 3, ...`

And it's easy enough to extend that to the *integers*, `..., -3, -2, -1, 0, 1, 2, 3, ...`

. And we're familiar with fractions (*rational* numbers) that also include `-1/2`

and `355/113`

. The *reals* are all those plus the numbers in between that can't be expressed by a fraction, things like `√2`

, or `π`

. There are many more real numbers than rational ones. (There are other collections in between, such as the *algebraic* numbers, which are mostly interesting to mathematicians.)

Real numbers are the logical units to use when discussing time (and no, I won't debate this point with my physicist son!) Time blocks are continuously divisible into smaller ones, so the reals, which easily represent a continuum, simply make sense.

I'm partial to the imaginary numbers, like

`√-5`

:)
@kurtmilam Yes,

`R.juxt`

works like this
`juxt([add(1), add(10)])(1) // [2, 11]`

:boom: That's the ticket! Time to say goodbye to my

`mapApplyTo`

:D
Thanks - I've used

`juxt`

, but it's been a while.
:smiley: :thumbsup:

We need a Roogle (Hoogle for Ramda).

Thanks - that's also handy. Bookmarked.

You're welcome!

I really do want to try to create a Hoogle, but we'd have to tame our signatures first.

I've still *never* used juxt and am not sure how it works :stuck_out_tongue:

I'm doing a bunch of plane geometry with line segments, points, etc.

`juxt`

makes it easy to turn an array of line segments into an array of tuples consisting of the segment length and segment starting point.
`R.juxt([f, g, h]) //=> (a, b, ...) => [f(a, b, ...), g(a, b, ...), h(a, b, ...)]`

Now I'm trying to figure out a

`getSegment`

length function that will work with segments in any number of dimensions.
FP is a code golfer's nightmare / paradise, depending on how you look at it :)

@kurtmilam Haha. +1. I'm actually less productive with Ramda thanks to the code-golfing. But the code looks so much better! (sometimes)

I have to fight hard sometimes to avoid code-golfing. Make it readable, damn it, Scott!

:thumbsup:

:angel:

I think this will get the length of any segment in any number of dimensions:

```
const getSegmentLength =
S.pipe([
R.apply ( R.zipWith ( R.subtract ) ),
R.map( x => x * x ),
R.sum,
Math.sqrt
])
// S is Sanctuary
```

I wrote one that worked in 2 dimensions, which is probably all I'll ever need, but I just can't leave good enough alone :laughing:

@kurtmilam: it certainly looks right.

:thumbsup: I get a special satisfaction from writing software that involves a little math (although this is super simple math).

Once I had to use some pretty interesting discrete math for a practical project. It isn't that common for what I do (web dev). I still use it in the "tell us somethingyou're proud of" part of interviews

Yeah, I love having those stories. Mine, believe it or not, was about writing a simplified XML parser in COBOL.

Oh that's fun

I am hoping that I can spend enough time on the server framework I am writing that I will be able to point to that

Nice to be working on something that might end up being one of those stories!

The most fun was explaining to the COBOL people that the XML parser they were using (the built in mainframe one in 2002) sucked and that we could do it better... and then proving it in three days. They'd believed no one could do it better than IBM. But their parser took the worst of both SAX and DOM. It loaded the entire document in memory, then delivered it only as a stream of events. It was really easy to just create a SAX parser (huge documents) as a state machine in Java, then port that code to COBOL.

That's really interesting

So what did you use discrete math for? And what sort of discrete math?

Oh, so I was building an appointment scheduling app, and there were rules dictating when people were allowed to schedule appointments. We needed to be able to efficiently determine whether or not two recurring appointments would overlap in the future, based on the recurrence schedule of each appointment.

It's easy for stuff like weekly appointments, but once you start with stuff like:

Appt A is every 5 weeks and appt B is every 12 weeks at the same time and day and Appt A starts 4 weeks before Appt B

it gets tricky

Not being a mathemetician, I wasn't aware of existing work that handled the overlapping of values on two different modular ... scales?

It's been a while, but I was able to derive some laws depending on the coprimality of the modulus and the distance between the start dates

I think gitter regex replacement is broken :-(

That's funny; I did something similar on my last job. It was for scheduling recurring jobs, not appointments, but very similar. Although I have a math background, I ended up simply checking every occurrence until the termination date rather than trying what you did. But yes, coprimality would be the key mathematically.

It was pretty fun, and efficient for the most important use case.

const t = {a: 'p', p: 'g'}

prop(prop('a')(t))(t)

is there a way to write this without calling (t) twice?

expected output is 'g'

@ram-bot

`converge(prop, [prop('a'), identity])({a: 'b', b: 'g'})`

ugh, rambot is down

but that works

`chain(prop, prop('a'))({a: 'b', b: 'g'})`

That does too

From the docs:

If second argument is a function, chain(f, g)(x) is equivalent to f(g(x), x).

:) thanks

:bowtie: I finally got to use the

`chain`

instance for functions
ahah

Interesting,

`chain(fn, identity)`

is the `W`

combinator :)