[racket-users] Making my own helper function

2020-07-23 Thread JJ C
I am in a course where I have to use beginning student with list abbreviation in Racket to do assignments. Below is my code for unique-right, which is supposed to return a list which has only the right most occurrences of the elements of list. The restriction in doing the asisngment is that I c

[racket-users] Removing duplicates in a list in Dr. Racket

2020-07-20 Thread JJ C
In Beginning Student with List Abbreviations I am struggling to come up with functions to remove duplicates from a list while maintaining the order of the list. one function to remove duplicates from the left, i.e. 1 2 1 3 2 4 5 -> 1 2 3 4 5 and one from the right. i.e. 1 2 1 3 2 4 5 -> 1 3

[racket-users] Removing duplicates from a list while still maintaining order in Dr. Racket.

2020-07-20 Thread JJ C
In Beginning Student with List Abbreviations I am struggling to come up with functions to remove duplicates from a list while maintaining the order of the list. one function to remove duplicates from the left, i.e. 1 2 1 3 2 4 5 -> 1 2 3 4 5 and one from the right. i.e. 1 2 1 3 2 4 5 -> 1 3

Re: [racket-users] do loops

2016-02-15 Thread JJ
> it only requires O(log n) on a (balanced) search tree: sorry, O(log n) for conttains? and O(n log n) in total -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: [racket-users] do loops

2016-02-15 Thread JJ
Right, but evaluating tree-size is O(n), even with a binary search tree. Doing this on each insertion is slow. The following is a possible solution without "do", and it only requires O(log n) on a (balanced) search tree: (define tree5 (let loop ([tree null] [n 5]) (define x (random 10))

[racket-users] do loops

2016-02-14 Thread JJ
I try to fill a binary tree with 5 random numbers, avoiding duplicates. Is there a more elegant way than this (using "Iterations and Comprehensions")? (define tree4 (do ([x (random 10) (random 10)] [c #f (contains? tree x)] [tree null (if c tree (insert tree x))] [i 0 (if c