1
$\begingroup$

I tried do define two OIES Sequences like that:

A035327[n_]:=ResourceFunction["OEISSequence"]["A035272"][[n]]
A360142[n_]:=ResourceFunction["OEISSequence"]["A360142"][[n]]

So the argument n takes the corresponding Part of the sequence List

But then

A035327[A360142[1]]

returns

List

If not "nested" it works fine.

What am I doing wrong?

$\endgroup$
3
  • 1
    $\begingroup$ It looks like A035327[0] isn't defined! $\endgroup$ Mar 3 at 11:03
  • $\begingroup$ Darn! Iam sorry, too stupid!! Shall I delete the question? $\endgroup$ Mar 3 at 11:10
  • $\begingroup$ Let the community decide. It will be very likely closed. But as for deleted, I'm not so sure. $\endgroup$
    – rhermans
    Mar 3 at 11:12

1 Answer 1

4
$\begingroup$

Explanation

It's not about nesting, it's about the argument. You are doing {a,b,c}[[0]].

ResourceFunction["OEISSequence"]["A360142"]
(* {0,1,2,2,4,5,8,9,10,17,18,18,20,35,36,37,40,69,73,74,81,138,145,146,146,148,163,276,291,292,293,296,325,553,582,585,586,593,650,1105,1162,1169,1170,1172,1187,1300,2211,2324,2339,2340,2341,2344,2373,2601} *)

A360142[1]
(* 0 *)

So

A035327[A360142[1]]

is the same as

A035327[0]

Part zero of any expression is its Head

enter image description here

Therefore,

A035327[0]
(* List *)

As well as

{0,1,2,2,4,5}[[0]]
(* List *)

Solution

ClearAll[A035327,A360142,A035272];
A035272[n_Integer?17>=n>=1] := ResourceFunction["OEISSequence"]["A035272"][[n]]
A360142[n_Integer?54>=n>=1] := ResourceFunction["OEISSequence"]["A360142"][[n]]
$\endgroup$
2
  • $\begingroup$ Yeah thanks a lot, how embarassing!! $\endgroup$ Mar 3 at 11:11
  • 1
    $\begingroup$ @RaphaelJ.F.Berger not embarrassing we all make mistakes, in my case, many times a day. In the future try debugging with Echo and Trace. $\endgroup$
    – rhermans
    Mar 3 at 11:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.