Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Answered
Can I dynamically add refs into the builder type?

I have function like this:

() save_data_on_update(slice destination_address) impure inline {
  builder q = begin_cell();

  builder qSliceDestinationAddress = q.store_slice(destination_address);

  builder qRefs = qSliceDestinationAddress.store_ref(
      begin_cell().store_uint(0, 1).end_cell()
    )
    .store_ref(
      begin_cell().store_uint(0, 1).end_cell()
    )
    .store_ref(
      begin_cell().store_uint(0, 1).end_cell()
    )
    .store_ref(
      begin_cell().store_uint(0, 1).end_cell()
    );
  
  cell endedQ = qRefs.end_cell();

  set_data(endedQ);
}

Сan I write a function like this?

() save_data_on_update(slice destination_address) impure inline {
  builder q = begin_cell();

  builder qSliceDestinationAddress = q.store_slice(destination_address);

  builder qRefs = qSliceDestinationAddress;
  
  int x = 0;

  while (x < 5) {
    x += 1;
    qRefs.store_ref(begin_cell().store_uint(0, 1).end_cell());
  }

  cell endedQ = qRefs.end_cell();

  set_data(endedQ);
}
Votes Newest

Answers


With a minor change, you can. In the while loop, assign qRefs.store_ref to qRefs. In fact you don't need to keep references to the old builder. I would write it like this:

() save_data_on_update(slice destination_address) impure inline {
  builder b = begin_cell();
	b = b.store_slice(destination_address);
	repeat (4) {
	  b = b.store_ref(begin_cell().store_uint(0, 1).end_cell());
	}
	cell c = b.end_cell();
	set_data(c);
}
  
  

nice.

Howard   12 months ago Report
  
  

well done

Howard   8 months ago Report
18K Views
1 Answer
one year ago
one year ago
Tags