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

Implicitly round/floor float when multiplying with an array/string/etc. #247

Open
xPMo opened this issue Feb 10, 2018 · 3 comments
Open

Comments

@xPMo
Copy link
Contributor

xPMo commented Feb 10, 2018

An answer to a recent challenge had to floor a float in order to multiply by a string. If a floor is not explicitly provided, Pyth simply errors out.

There are two directions that this can go:

  1. round/floor before multiplying: *c5 2"ab" -> abab

  2. append that fraction (rounded/floored) of the string/list: *c5 2"ab" -> ababa

I don't know which way would be better, but either way shouldn't cause any regressions.

@Steven-Hewitt
Copy link
Contributor

Steven-Hewitt commented Feb 10, 2018

I wouldn't quite call my answer recent, but this could be a nice change.

However, I'd recommend keeping the old behavior on one of the two permutations (preferably * <num> <seq>, so that we can hack a check for floats with .x*TG (where we're checking T for floatiness, and G is the current global value of "abc...yz".)

@ConorOBrien-Foxx
Copy link

I'm not a Pyth expert, but wouldn't is just be better to have a float check builtin? IIRC there are some open commands.

@Mr-Xcoder
Copy link

Mr-Xcoder commented Feb 10, 2018

I think we shouldn't go with rounding, because it can be rather confusing. Honestly, I think it should floor the argument. Regarding float check, it's not too hard to do it without a dedicated command (!sI). I think this functionality can be extended to:

  • Indexing (@).
  • Get first N (<)
  • Remove first N (>)
  • Cyclic rotations (.< and .>)

And perhaps even more. Another version for @ would be to return the elements at indices floor(argument) and ceil(argument), similar to how Jelly does it. What do you think?

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

No branches or pull requests

4 participants