Skip to main content
bugfixed
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106

Husk, 20 18 17 13 bytes

Thanks a lot @Zgarb for telling me about İf which is a built-in for Fibonacci numbers, this saved me 4 bytes:

´o↓=3↔`↑§↓=1ȯ↔`↑:0İf≤ 

Try it online!Try it online!

Ungolfed/Explanation

 -- implicit input N İf -- get all Fibonacci numbers, :0 -- prepend 0, `↑ ≤ -- take as as long as the number is ≤ N,   ȯ↔ -- reverse and  § =1 =3 -- if length of resultinput == 31: ´o↓ -- drop first1 element else no element 

Old answer without built-in (17 bytes)

The old answer is quite similar to shooqie's Haskell answer:

´o↓=3↔`↑ȯƒo§↓=1ȯ↔`↑ȯƒo:0G+1≤ 

Try it online!Try it online!

Ungolfed/Explanation

A really short way to compute Fibonacci numbers in Haskell is to define a recursive function like this (also see the Haskell answer):

fibos = 0 : scanl (+) 1 fibos 

Essentially that code computes the fixpoint of the function \f -> 0 : scanl (+) 1 f, so you can rewrite fibos in an anonymous way like this:

fix (\f -> 0 : scanl (+) 1 f) 

Try it online!

This corresponds to the Husk code (ƒo:0G+1), here's the remaining code annotated:

 -- implicit input N ȯƒo:0G+1 -- generate Fibonacci numbers (ȯ is to avoid brackets), `↑ ≤ -- take as as long as the number is ≤ N,   ȯ↔ -- reverse and  § =1 =3 -- if length of resultinput == 31: ´o↓ -- drop first1 element else no element 

Husk, 20 18 17 13 bytes

Thanks a lot @Zgarb for telling me about İf which is a built-in for Fibonacci numbers, this saved me 4 bytes:

´o↓=3↔`↑:0İf≤ 

Try it online!

Ungolfed/Explanation

 -- implicit input N İf -- get all Fibonacci numbers, :0 -- prepend 0, `↑ ≤ -- take as as long as the number is ≤ N,    -- reverse and   =3 -- if length of result == 3: ´o↓ -- drop first element 

Old answer without built-in (17 bytes)

The old answer is quite similar to shooqie's Haskell answer:

´o↓=3↔`↑ȯƒo:0G+1≤ 

Try it online!

Ungolfed/Explanation

A really short way to compute Fibonacci numbers in Haskell is to define a recursive function like this (also see the Haskell answer):

fibos = 0 : scanl (+) 1 fibos 

Essentially that code computes the fixpoint of the function \f -> 0 : scanl (+) 1 f, so you can rewrite fibos in an anonymous way like this:

fix (\f -> 0 : scanl (+) 1 f) 

Try it online!

This corresponds to the Husk code (ƒo:0G+1), here's the remaining code annotated:

 -- implicit input N ȯƒo:0G+1 -- generate Fibonacci numbers (ȯ is to avoid brackets), `↑ ≤ -- take as as long as the number is ≤ N,    -- reverse and   =3 -- if length of result == 3: ´o↓ -- drop first element 

Husk, 20 18 17 13 bytes

Thanks a lot @Zgarb for telling me about İf which is a built-in for Fibonacci numbers, this saved me 4 bytes:

§↓=1ȯ↔`↑:0İf≤ 

Try it online!

Ungolfed/Explanation

 -- implicit input N İf -- get all Fibonacci numbers, :0 -- prepend 0, `↑ ≤ -- take as as long as the number is ≤ N, ȯ↔ -- reverse and § =1 -- if input == 1:  -- drop 1 element else no element 

Old answer without built-in (17 bytes)

The old answer is quite similar to shooqie's Haskell answer:

§↓=1ȯ↔`↑ȯƒo:0G+1≤ 

Try it online!

Ungolfed/Explanation

A really short way to compute Fibonacci numbers in Haskell is to define a recursive function like this (also see the Haskell answer):

fibos = 0 : scanl (+) 1 fibos 

Essentially that code computes the fixpoint of the function \f -> 0 : scanl (+) 1 f, so you can rewrite fibos in an anonymous way like this:

fix (\f -> 0 : scanl (+) 1 f) 

Try it online!

This corresponds to the Husk code (ƒo:0G+1), here's the remaining code annotated:

 -- implicit input N ȯƒo:0G+1 -- generate Fibonacci numbers (ȯ is to avoid brackets), `↑ ≤ -- take as as long as the number is ≤ N, ȯ↔ -- reverse and § =1 -- if input == 1:  -- drop 1 element else no element 
-4 bytes
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106

Husk, 20 18 1717 13 bytes

ThisThanks a lot @Zgarb for telling me about İf which is a built-in for Fibonacci numbers, this saved me 4 bytes:

´o↓=3↔`↑:0İf≤ 

Try it online!

Ungolfed/Explanation

 -- implicit input N İf -- get all Fibonacci numbers, :0 -- prepend 0, `↑ ≤ -- take as as long as the number is ≤ N, ↔ -- reverse and =3 -- if length of result == 3: ´o↓ -- drop first element 

Old answer without built-in (17 bytes)

The old answer is quite similar to shooqie's Haskell answer:

´o↓=3↔`↑ȯƒo:0G+1≤ 

Try it online!

Ungolfed/Explanation

A really short way to compute Fibonacci numbers in Haskell is to define a recursive function like this (also see the Haskell answer):

fibos = 0 : scanl (+) 1 fibos 

Essentially that code computes the fixpoint of the function \f -> 0 : scanl (+) 1 f, so you can rewrite fibos in an anonymous way like this:

fix (\f -> 0 : scanl (+) 1 f) 

Try it online!

This corresponds to the Husk code (ƒo:0G+1), here's the remaining code annotated:

 -- implicit input N ȯƒo:0G+1 -- generate Fibonacci numbers (ȯ is to avoid brackets), `↑ ≤ -- take as as long as the number is ≤ N, ↔ -- reverse, and =3 -- if length of result == 3: ´o↓ -- drop first element 

Husk, 20 18 17 bytes

This answer is quite similar to shooqie's Haskell answer:

´o↓=3↔`↑ȯƒo:0G+1≤ 

Try it online!

Ungolfed/Explanation

A really short way to compute Fibonacci numbers in Haskell is to define a recursive function like this (also see the Haskell answer):

fibos = 0 : scanl (+) 1 fibos 

Essentially that code computes the fixpoint of the function \f -> 0 : scanl (+) 1 f, so you can rewrite fibos in an anonymous way like this:

fix (\f -> 0 : scanl (+) 1 f) 

Try it online!

This corresponds to the Husk code (ƒo:0G+1), here's the remaining code annotated:

 -- implicit input N ȯƒo:0G+1 -- generate Fibonacci numbers (ȯ is to avoid brackets), `↑ ≤ -- take as as long as the number is ≤ N, ↔ -- reverse, =3 -- if length of result == 3: ´o↓ -- drop first element 

Husk, 20 18 17 13 bytes

Thanks a lot @Zgarb for telling me about İf which is a built-in for Fibonacci numbers, this saved me 4 bytes:

´o↓=3↔`↑:0İf≤ 

Try it online!

Ungolfed/Explanation

 -- implicit input N İf -- get all Fibonacci numbers, :0 -- prepend 0, `↑ ≤ -- take as as long as the number is ≤ N, ↔ -- reverse and =3 -- if length of result == 3: ´o↓ -- drop first element 

Old answer without built-in (17 bytes)

The old answer is quite similar to shooqie's Haskell answer:

´o↓=3↔`↑ȯƒo:0G+1≤ 

Try it online!

Ungolfed/Explanation

A really short way to compute Fibonacci numbers in Haskell is to define a recursive function like this (also see the Haskell answer):

fibos = 0 : scanl (+) 1 fibos 

Essentially that code computes the fixpoint of the function \f -> 0 : scanl (+) 1 f, so you can rewrite fibos in an anonymous way like this:

fix (\f -> 0 : scanl (+) 1 f) 

Try it online!

This corresponds to the Husk code (ƒo:0G+1), here's the remaining code annotated:

 -- implicit input N ȯƒo:0G+1 -- generate Fibonacci numbers (ȯ is to avoid brackets), `↑ ≤ -- take as as long as the number is ≤ N, ↔ -- reverse and =3 -- if length of result == 3: ´o↓ -- drop first element 
typo
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106

Husk, 20 18 17 bytes

This answer is quite similar to shooqie's Haskell answer:

´o↓=3↔`↑ȯƒo:0G+1≤ 

Try it online!

Ungolfed/Explanation

A really short way to compute Fibonacci numbers in Haskell is to define a recursive function like this (also see the Haskell answer):

fibos = 0 : scanl (+) 1 fibos 

Essentially that code computes the fixpoint of the function \f -> 0 : scanl (+) 1 f, so you can rewrite fibos in an anonymous way like this:

fix (\f -> 0 : scanl (+) 1 f) 

Try it online!

This corresponds to the Husk code (ƒo:0G+1), here's the remaining code annotated:

 -- implicit input N ȯƒo:0G+ 0G+1 -- generate Fibonacci numbers (ȯ is to avoid brackets), `↑ 1≤ -- take takeas as untillong >as the number is ≤ N, ↔ -- reverse, =3 -- if length of result == 3: ´o↓ -- drop first element 

Husk, 20 18 17 bytes

This answer is quite similar to shooqie's Haskell answer:

´o↓=3↔`↑ȯƒo:0G+1≤ 

Try it online!

Ungolfed/Explanation

A really short way to compute Fibonacci numbers in Haskell is to define a recursive function like this (also see the Haskell answer):

fibos = 0 : scanl (+) 1 fibos 

Essentially that code computes the fixpoint of the function \f -> 0 : scanl (+) 1 f, so you can rewrite fibos in an anonymous way like this:

fix (\f -> 0 : scanl (+) 1 f) 

Try it online!

This corresponds to the Husk code (ƒo:0G+1), here's the remaining code annotated:

 -- implicit input N ȯƒo:0G+  -- generate Fibonacci numbers (ȯ is to avoid brackets), `↑ 1≤ -- take take as until > N, ↔ -- reverse, =3 -- if length of result == 3: ´o↓ -- drop first element 

Husk, 20 18 17 bytes

This answer is quite similar to shooqie's Haskell answer:

´o↓=3↔`↑ȯƒo:0G+1≤ 

Try it online!

Ungolfed/Explanation

A really short way to compute Fibonacci numbers in Haskell is to define a recursive function like this (also see the Haskell answer):

fibos = 0 : scanl (+) 1 fibos 

Essentially that code computes the fixpoint of the function \f -> 0 : scanl (+) 1 f, so you can rewrite fibos in an anonymous way like this:

fix (\f -> 0 : scanl (+) 1 f) 

Try it online!

This corresponds to the Husk code (ƒo:0G+1), here's the remaining code annotated:

 -- implicit input N ȯƒo:0G+1 -- generate Fibonacci numbers (ȯ is to avoid brackets), `↑  -- take as as long as the number is ≤ N, ↔ -- reverse, =3 -- if length of result == 3: ´o↓ -- drop first element 
-1 byte
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106
Loading
-2 now
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106
Loading
-1 byte, no idea what I was thinking..
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106
Loading
Source Link
ბიმო
  • 17k
  • 3
  • 43
  • 106
Loading