Skip to content

Commit

Permalink
2024-03-24 point, record
Browse files Browse the repository at this point in the history
  • Loading branch information
nomagicisreal committed Mar 24, 2024
1 parent ede1b8d commit 89f36c1
Show file tree
Hide file tree
Showing 39 changed files with 3,070 additions and 2,956 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
## 0.0.1 ~ 0.0.18
## 0.0.1 ~ 0.0.19
- Initial version.
11 changes: 5 additions & 6 deletions bin/cmd.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// import 'dart:math';

// import 'dart:math' as math;
// import 'package:damath/src/experiment/experiment.dart';
// import 'package:damath/src/math/math.dart';

void main(List<String> arguments) async {
// const d1 = 'the computer is complex';
Expand All @@ -18,11 +18,9 @@ void main(List<String> arguments) async {
// final result = (pF | -qF) > (pF & qF);
// print(result);

// final list = [1, 3, 1, 2, 6, 10, -1, 8];
// print((1, 2) == (1, 2));
// print(list.iterator.cumulativeWhere((value) => value.isOdd));
}
// watching();

}

void watching() {
final watch = Stopwatch();
Expand All @@ -36,3 +34,4 @@ void watching() {

print('end');
}

4 changes: 2 additions & 2 deletions lib/api.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library damath;

export 'src/async/async.dart';
export 'src/experiment/experiment.dart' hide DamathException;
export 'src/experiment/experiment.dart';
export 'src/flutter/flutter.dart';
export 'src/math/math.dart';
export 'src/math/math.dart' hide DamathException;
2 changes: 1 addition & 1 deletion lib/src/async/async.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import 'package:damath/src/math/math.dart';

part 'general/core.dart';
part 'general/extension.dart';
part 'general/definition.dart';
part 'general/beats.dart';
File renamed without changes.
7 changes: 6 additions & 1 deletion lib/src/async/general/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
///
/// this file contains:
/// [Listener]
/// [Decider]
/// [Supporter]
/// [Sequencer]
///
///
/// extensions:
Expand All @@ -18,7 +21,7 @@ part of damath_async;
typedef Listener = void Function();
typedef Decider<T, S> = Consumer<T> Function(S toggle);
typedef Supporter<T> = T Function(Supplier<int> indexing);
typedef Sequencer<T, I, S> = Translator<int, S> Function(
typedef Sequencer<T, I, S> = Mapper<int, S> Function(
T previous,
T next,
I interval,
Expand All @@ -33,4 +36,6 @@ extension FListener on Listener {
static void none() {}

Future<void> delayed(Duration duration) => Future.delayed(duration, this);

static final delayedZero = Future.delayed(Duration.zero);
}
6 changes: 3 additions & 3 deletions lib/src/async/general/extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ extension FStream<T> on Stream<T> {
static Stream<int> ofInts({
int start = 0,
int end = 10,
Duration delay = KDuration.second1,
Duration delay = KMath.durationSecond1,
}) async* {
assert(end >= start);
for (var i = start; i <= end; i++) {
Expand All @@ -104,7 +104,7 @@ extension FStream<T> on Stream<T> {
static Stream<int> intOf({
int start = 1,
int end = 10,
Duration interval = KDuration.second1,
Duration interval = KMath.durationSecond1,
bool startWithDelay = true,
}) async* {
Future<int> yielding(int value) async =>
Expand Down Expand Up @@ -159,7 +159,7 @@ extension FTimer on Timer {
Iterable<Duration> steps,
Iterable<Listener> listeners,
) =>
_sequence(steps.iterator.interYieldingEntry(listeners.iterator));
_sequence(steps.iterator.interYieldingToEntry(listeners.iterator));
}

extension FTimerConsumer on Consumer<Timer> {
Expand Down
78 changes: 43 additions & 35 deletions lib/src/experiment/definition/_additions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
///
/// [Operator]
///
/// [Spherical]
///
///
///
///
///
Expand Down Expand Up @@ -55,49 +52,61 @@ class DurationFR {
: forward = duration,
reverse = duration;

///
///
/// constants
///
///
static const DurationFR zero = DurationFR.constant(Duration.zero);
static const milli100 = DurationFR.constant(KMath.durationMilli100);
static const milli300 = DurationFR.constant(KMath.durationMilli300);
static const milli500 = DurationFR.constant(KMath.durationMilli500);
static const milli800 = DurationFR.constant(KMath.durationMilli800);
static const second1 = DurationFR.constant(KMath.durationSecond1);
static const second2 = DurationFR.constant(KMath.durationSecond2);
static const second3 = DurationFR.constant(KMath.durationSecond3);
static const second4 = DurationFR.constant(KMath.durationSecond4);
static const second5 = DurationFR.constant(KMath.durationSecond5);
static const second6 = DurationFR.constant(KMath.durationSecond6);
static const second7 = DurationFR.constant(KMath.durationSecond7);
static const second8 = DurationFR.constant(KMath.durationSecond8);
static const second9 = DurationFR.constant(KMath.durationSecond9);
static const second10 = DurationFR.constant(KMath.durationSecond10);
static const min1 = DurationFR.constant(KMath.durationMin1);

DurationFR operator ~/(int value) =>
DurationFR(forward ~/ value, reverse ~/ value);

DurationFR operator +(Duration value) =>
DurationFR(forward + value, reverse + value);

DurationFR operator -(Duration value) =>
DurationFR(forward - value, reverse - value);

///
///
/// implementation for [Object]
///
///
@override
int get hashCode => Object.hash(forward, reverse);

@override
bool operator ==(covariant DurationFR other) => hashCode == other.hashCode;

@override
String toString() => 'DurationFR(forward: $forward, reverse:$reverse)';
String toString() => 'DurationFR(f: $forward, r:$reverse)';

///
/// constants
///
///
///
DurationFR operator +(DurationFR other) =>
DurationFR(forward + other.forward, reverse + other.reverse);

DurationFR operator -(DurationFR other) =>
DurationFR(forward - other.forward, reverse - other.reverse);

DurationFR operator &(Duration value) =>
DurationFR(forward + value, reverse + value);

DurationFR operator ^(Duration value) =>
DurationFR(forward - value, reverse - value);

DurationFR operator ~/(int value) =>
DurationFR(forward ~/ value, reverse ~/ value);

static const milli100 = DurationFR.constant(KDuration.milli100);
static const milli300 = DurationFR.constant(KDuration.milli300);
static const milli500 = DurationFR.constant(KDuration.milli500);
static const milli800 = DurationFR.constant(KDuration.milli800);
static const milli1500 = DurationFR.constant(KDuration.milli1500);
static const milli2500 = DurationFR.constant(KDuration.milli2500);
static const second1 = DurationFR.constant(KDuration.second1);
static const second2 = DurationFR.constant(KDuration.second2);
static const second3 = DurationFR.constant(KDuration.second3);
static const second4 = DurationFR.constant(KDuration.second4);
static const second5 = DurationFR.constant(KDuration.second5);
static const second6 = DurationFR.constant(KDuration.second6);
static const second7 = DurationFR.constant(KDuration.second7);
static const second8 = DurationFR.constant(KDuration.second8);
static const second9 = DurationFR.constant(KDuration.second9);
static const second10 = DurationFR.constant(KDuration.second10);
static const second20 = DurationFR.constant(KDuration.second20);
static const second30 = DurationFR.constant(KDuration.second30);
static const min1 = DurationFR.constant(KDuration.min1);
}

///
Expand Down Expand Up @@ -188,12 +197,11 @@ enum Operator {
///
/// mapper
///
Mapper<double> doubleMapperOf(double value) => switch (this) {
Applier<double> doubleMapperOf(double value) => switch (this) {
Operator.plus => (a) => a + value,
Operator.minus => (a) => a - value,
Operator.multiply => (a) => a * value,
Operator.divide => (a) => a / value,
Operator.modulus => (a) => a % value,
};
}

6 changes: 2 additions & 4 deletions lib/src/experiment/definition/proposition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,8 @@ class PropositionCompound extends PropositionComponent {
/// [_foldPropositionsToSet]
///
Set<K> _foldPropositionsToSet<K>(
Translator<Proposition, K> toK,
Translator<PropositionCompound, Set<K>> toKSet,
Mapper<Proposition, K> toK,
Mapper<PropositionCompound, Set<K>> toKSet,
) =>
_components.fold(
{},
Expand Down Expand Up @@ -527,5 +527,3 @@ extension SetPropositionCompoundExtension on Set<PropositionCompound> {
).isConsistent;
}



2 changes: 1 addition & 1 deletion lib/src/experiment/definition/statistic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class StatisticsForDataframe extends Statistics {
const StatisticsForDataframe();
}

// mean, median, mode
// median, mode
// measures of variation
// - range, interquaretile range
// - variance, standard deviation, deviations from mean)
10 changes: 1 addition & 9 deletions lib/src/experiment/experiment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@ import 'package:damath/src/math/math.dart';


part 'definition/_additions.dart';
part 'definition/graph.dart';
part 'graph/graph.dart';
part 'definition/proposition.dart';
part 'definition/statistic.dart';
part 'space/tensor.dart';
part 'space/space.dart';
part 'space/direction.dart';
part 'general/core.dart';
part 'general/value.dart';


class DamathException implements Exception {
final String message;
DamathException(this.message);

@override
String toString() => 'DamathException: $message';
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Node<T> extends Vertex<T> {
Node(super.data, [this.another]);

Node.fromData(super.data, [T? another])
: another = another.nullOrTranslate((value) => Node(value));
: another = another.nullOrMap((value) => Node(value));

///
/// [isLinked]
Expand Down Expand Up @@ -168,8 +168,8 @@ class NodeBinary<T> extends Vertex<T> {
NodeBinary(super.data, {this.left, this.right});

NodeBinary.fromData(super.data, {T? left, T? right})
: left = left.nullOrTranslate((value) => NodeBinary(value)),
right = right.nullOrTranslate((value) => NodeBinary(value));
: left = left.nullOrMap((value) => NodeBinary(value)),
right = right.nullOrMap((value) => NodeBinary(value));

static String stringDiagramOf<E>(
NodeBinary<E>? node, [
Expand Down Expand Up @@ -276,13 +276,12 @@ class NodeBinary<T> extends Vertex<T> {
}

bool any(Predicator<T> test) {
const pass = 'pass';
try {
iterateFromLeftToRight((value) {
if (test(value)) throw DamathException(pass);
if (test(value)) throw DamathException(DamathException.pass);
});
} on DamathException catch (e) {
return e.message == pass;
return e.message == DamathException.pass;
}
return false;
}
Expand Down Expand Up @@ -676,8 +675,8 @@ abstract class GraphAncestor<T, S, V extends VertexAncestor<T?>,
/// [sourcesGroupByDestinations]
///
Map<K, List<D>> vertexGroupsFromEdges<K, D>(
Translator<E, K> edgeToKey,
Translator<E, D> edgeToValue,
Mapper<E, K> edgeToKey,
Mapper<E, D> edgeToValue,
) =>
edges.fold(
{},
Expand Down Expand Up @@ -735,12 +734,12 @@ abstract class GraphAncestor<T, S, V extends VertexAncestor<T?>,
Iterable<E> edgesTo(V destination) =>
edges.where((edge) => edge._destination == destination);

Iterable<V> destinationsFrom(V source) => edges.iterator.yieldingWhereTo(
Iterable<V> destinationsFrom(V source) => edges.iterator.yieldingToWhere(
(edge) => edge._source == source,
(edge) => edge._destination,
);

Iterable<V> sourcesTo(V destination) => edges.iterator.yieldingWhereTo(
Iterable<V> sourcesTo(V destination) => edges.iterator.yieldingToWhere(
(edge) => edge._destination == destination,
(edge) => edge._source,
);
Expand Down
Loading

0 comments on commit 89f36c1

Please sign in to comment.