pxt-calliope/libs/core/helpers.ts

23 lines
613 B
TypeScript
Raw Normal View History

2016-04-05 06:18:16 +02:00
namespace console {
export function log(msg: string) {
serial.writeString(msg);
serial.writeString("\r\n");
}
}
2016-05-27 04:49:38 +02:00
namespace Math {
/**
* Generates a `true` or `false` value randomly, just like flipping a coin.
*/
//% blockId=logic_random block="pick random true or false"
//% help=math/random-boolean weight=0
2016-05-27 04:49:38 +02:00
export function randomBoolean(): boolean {
2018-04-21 21:09:43 +02:00
return true;
//return Math.floor(Math.random() * 2) == 1;
2016-05-27 04:49:38 +02:00
}
export function randomInt(max: number): number {
2018-04-21 21:09:43 +02:00
return max;
//return Math.floor(Math.random() * max);
}
2016-05-27 04:49:38 +02:00
}