Ad
  • Custom User Avatar
    console.log("List.repeat([1,2,3]).concat().take(4)");
    Test.assertDeepEquals( List.repeat(List.fromList([1,2,3])).concat().take(4).toList(), [1,2,3,1] );
    

    It's passing a List, just as the description of concat requires, and expecting a List. The actual testing is done on an Array.

    If you are unsure, it might help to console.log the input.

  • Default User Avatar

    It's the 6-th test on 'concat' suite in final tests. List.repeat([1,2,3]).concat().take(4) Expected: [1, 2, 3, 1] This error and the description of concat method - "list must be a list of lists" made me think that repeat on arrays should return list of lists otherwise List.repeat([1,2,3]).concat() should throw an error.

  • Custom User Avatar

    I can't find the exact reference ( there are a lot of tests .. ), but it's only a test header ( I think ). You should be able to take the description at its word, so when List.repeat is passed a List, you have to repeat that List, and not some array. If it were passed an Array, you'd have to repeat that. This may be somewhat complicated by the fact I can't directly test on Lists, so I have to convert them back to Arrays for testing.

    If you have questions about specific tests, please tell me where to find that test.

  • Default User Avatar

    Oh, thanks, I got it. My List has passed all sample tests but I am still struggling with infinite lists in the main tests. If you don't mind I have question about repeat function.
    From the description "List.repeat(x) => an infinite list, every element of which is x" it was not abvious (for me) that List.repeat([1,2,3]) create a list of lists and not list of arrays. Should we treat every array as list ?

  • Custom User Avatar

    That is the expected behaviour ( the error message could have been clearer ). Why are you evaluating the fold function over an empty list?

    Note that you have mangled the test line by not quoting it as code. The full line is Test.assertDeepEquals( List.empty.foldr( () => _|_ , Math.E ), Math.E ); but MarkDown uses _ as <i>.

    If you want a clearer error message, change _|_ to { throw new Error("I must never be evaluated"); }

  • Default User Avatar

    Hi, I have error message caused by test line Test.assertDeepEquals( List.empty.foldr( () => | , Math.E ), Math.E ); ReferenceError: _ is not defined