First time here? Check out the FAQ!

Capytalk logic in creating an array

+1 vote
I'm running into something I really don't understand why it isn't working.

I'm trying to create an array with

(1 to: 128) collect: [ :i | ((i mod: !N) eq: 0) true: 1 false: 0 ]

Which is supposed to generate a 1 every N place in the array the rest should be 0... But when running it only works when !N is 2, 4, 8, 16 and so on. With any other number it just becomes a big array of 1. I tried this as well

(1 to: 128) collect: [ :i | ((i mod: !N) eq: 0) ]

When I realised that true or false is just 1 and 0 anyway.

If i write

(1 to: 128) collect: [ :i | ((i mod: 3) eq: 0) true: 1 false: 0 ]

Everything is fine, so i expect to be something with turning it in to a eventvalue that causes the trouble, but i have no idea why. Am i doing something wrong with the logic, or breaking some rule about array creation?

asked Apr 5, 2018 in Capytalk & Smalltalk by anders-skibsted (Adept) (1,170 points)
Hi Anders, How are you using the Array? Are you using them as triggers in a Gate or Trigger field?
I use it in an SyntheticSpectrumFromArray.
I want to cancel out amplitudes in a spectral analysis signal.
So i kind of try to create a pulsetrain, but one that, for this purpose, is a bit easier to control than a real pulsetrain module.

1 Answer

+1 vote
Best answer

We have found and fixed a problem with the Capytalk mod: function when the receiver is a constant value and the argument is an Event Expression. This fix will be in the next update of Kyma (avaiable sometime in the next few days).

Thanks for pointing this out!

answered Apr 7, 2018 by ssc (Savant) (113,610 points)
selected Apr 7, 2018 by anders-skibsted
Thank you! I thought I was going crazy not getting it to work... nice to hear that it was mod: and not me.