Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logarithmic and exponential functions #552

Closed
axcmp opened this issue Sep 12, 2019 · 4 comments
Closed

Logarithmic and exponential functions #552

axcmp opened this issue Sep 12, 2019 · 4 comments

Comments

@axcmp
Copy link

axcmp commented Sep 12, 2019

Suggesting the implementation of logarithmic and exponential functions into Tidal.

log function prototype

log x base

Base could be optional, with e being the default value.

Example results:

log 1000 == 6.907755278982137

log 1000 10 == 3

log 1000 2 == 9.965784284662087

etc.

d1 $ s “sample”
	# speed (slow 2 $ log ((run 100) + 1) 100)

exp function prototype

exp x

Example result:

exp 2 == 7.38905609893065

d1 $ s “sample”
	# speed (exp (rand))
@bgold-cosmos
Copy link
Contributor

log and exp already exist in Haskell, and Haskell does not allow optional (default) function arguments

@axcmp
Copy link
Author

axcmp commented Sep 12, 2019

@bgold-cosmos Thank you for your answer. Do you know where I can find information on how to use them in Tidal?
I couldn’t find it at Tidal’s user base, that’s one of the reasons why I opened this issue.

@bgold-cosmos
Copy link
Contributor

I don't know if there's explicit documentation, but you can use exp and log on patterns as if they were numbers. From your example:

d1 $ s "sample" # speed (slow 2 $ log (run 100 + 1))

should just work, although Haskell's log is base e. You can get base b by just dividing by log b:

d1 $ s "sample" # speed (slow 2 $ log (run 100 + 1) / log 100)

@axcmp
Copy link
Author

axcmp commented Sep 23, 2019

@bgold-cosmos Yes, this may be it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants