I have defined the list structure and now I am trying to create a list with some rules. Here is the code:
List: aa
| i start current aNumber|
start := Test new setValue:2.
current := start.
aNumber:=3.
i:=0.
[i<=aa] whileTrue:[
current:=start.
[aNumber \\ current =0] whileFalse:
[[current getNext = nil] ifTrue:[current addLinkedVlue:aNumber. i=i+1].current:=current getNext].
aNumber:=aNumber+1].
I have a printListFrom method that gets the aa parameter. The goal is to get a list that has aa length. The list cannot contain numbers that can be divided without being reminded by the numbers that are already on the list. For example, if the list contains numbers: 2 3 5, and we need to check 6, then 6/2 = 3, it does not have a reminder, so we cannot add it to the list. If we want to check 7, then 7/2 = 3 reminder 1, 7/3 = 2 reminder 1, 7/5 = 1 reminder 2, in this case we can add 7 to the list.
aa = 3, , 3 (2 3 5), aa = 4, (2 3 5 7) ..
whileTrue aNumber (), 0, 1 aNumber, 0, aNumber , aNumber , 1 i, , aNumber .
, :
MessageNotUnderstood: adaptToNumber:andSend:
, .
, List:
setValue: i
a := i.
getNext
^next
addLinkedValue: n
next := Test new setValue: n.