SlideShare una empresa de Scribd logo
1 de 17
Descargar para leer sin conexión
9.2.3 Lazy Representations
9.2.1 Binary Random-Access Lists
type 'a tree = LEAF of 'a
              | NODE of int * 'a tree * 'a tree
    type 'a digit = ZERO
               | ONE of 'a tree
    type rlist = Element.t digit list

    let rec consTree = function
      | (t, []) -> [ONE t]
      | (t, ZERO :: ts) -> ONE t :: ts
      | (t1, ONE t2 :: ts) -> ZERO :: consTree (link (t1, t2), ts)
    ;;

    let rec unconsTree = function
      | [] -> raise Empty
      | [ONE t] -> (t, [])
      | (ONE t :: ts) -> (t, ZERO :: ts)
      | (ZERO :: ts) ->
          let (NODE (_, t1, t2), ts') = unconsTree ts in
          (t1, ONE t2 :: ts')
    ;;
9.2.2 Zeroless Representations
type 'a tree = LEAF of 'a
              | NODE of int * 'a tree * 'a tree
    type 'a digit = ONE of 'a tree
               | TWO of 'a tree * 'a tree
    type rlist = Elem.t digit list

    let rec consTree = function
      | (t, []) -> [ONE t]
      | (t1, ONE t2 :: ts) -> TWO (t1, t2) :: ts
      | (t1, TWO (t2, t3) :: ts) -> ONE t1 :: consTree (link (t2, t2), ts)
    ;;

    let rec unconsTree = function
      | [] -> raise Empty
      | [ONE t] -> (t, [])
      | (ONE t1 :: ts) ->
          let (NODE (_, t2, t3), ts') = unconsTree ts in
          (t1, TWO (t2, t3) :: ts')
      | (TWO (t1, t2) :: ts) -> (t1, ONE t2 :: ts)
    ;;
9.2.3 Lazy Representations

Binomial Heapsに遅延評価を導入したら、
挿入がAmortized timeでO(1)になった。



      Binary Random Access List の cons 関数も
      O(1) Amortized Timeで実行可能なはず。
Amortized Analysisする中で、
データ構造をPersistentな使い方に対応させるには、
遅延評価を使って関数をIncrementalに変換する。
type 'a tree = LEAF of 'a
              | NODE of int * 'a tree * 'a tree
    type 'a digit = ZERO
               | ONE of 'a tree
    type rlist = Elem.t digit S.stream

    let rec consTree = function
      | (t, lazy S.Nil) -> lazy (S.Cons (ONE t, lazy S.Nil))
      | (t1, lazy (S.Cons (ONE t2, ts))) -> lazy (S.Cons (ONE t1, consTree (link (t2, ts))))
      | (t, lazy (S.Cons (ZERO, ts))) -> lazy (S.Cons (ONE t, ts))
    ;;

    let rec unconsTree = function
      | (lazy S.Nil) -> raise Empty
      | (lazy (S.Cons (ONE t, lazy S.Nil))) -> (t, lazy S.Nil)
      | (lazy (S.Cons (ONE t, ts))) -> (t, (lazy (S.Cons (ZERO, ts))))
      | (lazy (S.Cons (ZERO, ts))) ->
          let (NODE (_, t1, t2), ts') = unconsTree ts in
          (t1, lazy (S.Cons (ONE t2, ts')))
    ;;
type 'a tree = LEAF of 'a
              | NODE of int * 'a tree * 'a tree
    type 'a digit = ZERO
               | ONE of 'a tree
               | TWO of 'a tree * 'a tree
    type rlist = Elem.t digit S.stream

    let rec consTree = function
      | (t, lazy S.Nil) -> lazy (S.Cons (ONE t, lazy S.Nil))
      | (t1, lazy (S.Cons (TWO (t2, t3), ts))) -> lazy (S.Cons (ONE t1, consTree (link (t2, t3), ts)))
      | (t1, lazy (S.Cons (ONE t2, ts))) -> lazy (S.Cons (TWO (t1, t2), ts))
      | (t, lazy (S.Cons (ZERO, ts))) -> lazy (S.Cons (ONE t, ts))
    ;;

    let rec unconsTree = function
      | (lazy S.Nil) -> raise Empty
      | (lazy (S.Cons (TWO (t1, t2), ts))) -> (t1, lazy (S.Cons (ONE t2, ts)))
      | (lazy (S.Cons (ONE t, lazy S.Nil))) -> (t, lazy S.Nil)
      | (lazy (S.Cons (ONE t, ts))) -> (t, (lazy (S.Cons (ZERO, ts))))
      | (lazy (S.Cons (ZERO, ts))) ->
          let (NODE (_, t1, t2), ts') = unconsTree ts in
          (t1, lazy (S.Cons (ONE t2, ts')))
    ;;
最下位桁から1が連続するとき、その連続部分の数の表現は一種類だけ。
つまり、すべてが1だけで構成される数のとき、表現は1つに収束する。
例えば、111と1111の間の数は様々な表現をもつが、
両端の111と1111はひとつずつしかない。
PFDS 9.2.3 Lazy Representations

Más contenido relacionado

Similar a PFDS 9.2.3 Lazy Representations

Similar a PFDS 9.2.3 Lazy Representations (20)

Python programming : List and tuples
Python programming : List and tuplesPython programming : List and tuples
Python programming : List and tuples
 
Lists.pptx
Lists.pptxLists.pptx
Lists.pptx
 
PFDS 4章をOCamlに翻訳
PFDS 4章をOCamlに翻訳PFDS 4章をOCamlに翻訳
PFDS 4章をOCamlに翻訳
 
Session -5for students.pdf
Session -5for students.pdfSession -5for students.pdf
Session -5for students.pdf
 
Advanced data structure
Advanced data structureAdvanced data structure
Advanced data structure
 
‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx
 
List_tuple_dictionary.pptx
List_tuple_dictionary.pptxList_tuple_dictionary.pptx
List_tuple_dictionary.pptx
 
Dependent Types with Idris
Dependent Types with IdrisDependent Types with Idris
Dependent Types with Idris
 
STRING LIST TUPLE DICTIONARY FILE.pdf
STRING LIST TUPLE DICTIONARY FILE.pdfSTRING LIST TUPLE DICTIONARY FILE.pdf
STRING LIST TUPLE DICTIONARY FILE.pdf
 
PRESENTATION ON TUPLES.pptx
PRESENTATION ON TUPLES.pptxPRESENTATION ON TUPLES.pptx
PRESENTATION ON TUPLES.pptx
 
Python Lecture 11
Python Lecture 11Python Lecture 11
Python Lecture 11
 
Pytho_tuples
Pytho_tuplesPytho_tuples
Pytho_tuples
 
python_avw - Unit-03.pdf
python_avw - Unit-03.pdfpython_avw - Unit-03.pdf
python_avw - Unit-03.pdf
 
The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196
 
least_action.pdf
least_action.pdfleast_action.pdf
least_action.pdf
 
The basics and design of lua table
The basics and design of lua tableThe basics and design of lua table
The basics and design of lua table
 
Revision Tour 1 and 2 complete.doc
Revision Tour 1 and 2 complete.docRevision Tour 1 and 2 complete.doc
Revision Tour 1 and 2 complete.doc
 
Pytho lists
Pytho listsPytho lists
Pytho lists
 
Ch5b
Ch5bCh5b
Ch5b
 
Zippers
ZippersZippers
Zippers
 

Más de 昌平 村山

PFDS 11.2 catenable double ended queue
PFDS 11.2 catenable double ended queuePFDS 11.2 catenable double ended queue
PFDS 11.2 catenable double ended queue昌平 村山
 
PFDS 10.2.2 heaps with efficient merging
PFDS 10.2.2 heaps with efficient mergingPFDS 10.2.2 heaps with efficient merging
PFDS 10.2.2 heaps with efficient merging昌平 村山
 
PFDS 10.2.1 lists with efficient catenation
PFDS 10.2.1 lists with efficient catenationPFDS 10.2.1 lists with efficient catenation
PFDS 10.2.1 lists with efficient catenation昌平 村山
 
PFDS 8.4.3 Real-Time Deques
PFDS 8.4.3 Real-Time DequesPFDS 8.4.3 Real-Time Deques
PFDS 8.4.3 Real-Time Deques昌平 村山
 
PFDS 5.5 Pairing heap
PFDS 5.5 Pairing heapPFDS 5.5 Pairing heap
PFDS 5.5 Pairing heap昌平 村山
 

Más de 昌平 村山 (6)

PFDS 11.2 catenable double ended queue
PFDS 11.2 catenable double ended queuePFDS 11.2 catenable double ended queue
PFDS 11.2 catenable double ended queue
 
PFDS 10.2.2 heaps with efficient merging
PFDS 10.2.2 heaps with efficient mergingPFDS 10.2.2 heaps with efficient merging
PFDS 10.2.2 heaps with efficient merging
 
PFDS 10.2.1 lists with efficient catenation
PFDS 10.2.1 lists with efficient catenationPFDS 10.2.1 lists with efficient catenation
PFDS 10.2.1 lists with efficient catenation
 
PFDS chart
PFDS chartPFDS chart
PFDS chart
 
PFDS 8.4.3 Real-Time Deques
PFDS 8.4.3 Real-Time DequesPFDS 8.4.3 Real-Time Deques
PFDS 8.4.3 Real-Time Deques
 
PFDS 5.5 Pairing heap
PFDS 5.5 Pairing heapPFDS 5.5 Pairing heap
PFDS 5.5 Pairing heap
 

Último

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Último (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

PFDS 9.2.3 Lazy Representations

  • 3. type 'a tree = LEAF of 'a | NODE of int * 'a tree * 'a tree type 'a digit = ZERO | ONE of 'a tree type rlist = Element.t digit list let rec consTree = function | (t, []) -> [ONE t] | (t, ZERO :: ts) -> ONE t :: ts | (t1, ONE t2 :: ts) -> ZERO :: consTree (link (t1, t2), ts) ;; let rec unconsTree = function | [] -> raise Empty | [ONE t] -> (t, []) | (ONE t :: ts) -> (t, ZERO :: ts) | (ZERO :: ts) -> let (NODE (_, t1, t2), ts') = unconsTree ts in (t1, ONE t2 :: ts') ;;
  • 5. type 'a tree = LEAF of 'a | NODE of int * 'a tree * 'a tree type 'a digit = ONE of 'a tree | TWO of 'a tree * 'a tree type rlist = Elem.t digit list let rec consTree = function | (t, []) -> [ONE t] | (t1, ONE t2 :: ts) -> TWO (t1, t2) :: ts | (t1, TWO (t2, t3) :: ts) -> ONE t1 :: consTree (link (t2, t2), ts) ;; let rec unconsTree = function | [] -> raise Empty | [ONE t] -> (t, []) | (ONE t1 :: ts) -> let (NODE (_, t2, t3), ts') = unconsTree ts in (t1, TWO (t2, t3) :: ts') | (TWO (t1, t2) :: ts) -> (t1, ONE t2 :: ts) ;;
  • 6. 9.2.3 Lazy Representations Binomial Heapsに遅延評価を導入したら、 挿入がAmortized timeでO(1)になった。 Binary Random Access List の cons 関数も O(1) Amortized Timeで実行可能なはず。
  • 8. type 'a tree = LEAF of 'a | NODE of int * 'a tree * 'a tree type 'a digit = ZERO | ONE of 'a tree type rlist = Elem.t digit S.stream let rec consTree = function | (t, lazy S.Nil) -> lazy (S.Cons (ONE t, lazy S.Nil)) | (t1, lazy (S.Cons (ONE t2, ts))) -> lazy (S.Cons (ONE t1, consTree (link (t2, ts)))) | (t, lazy (S.Cons (ZERO, ts))) -> lazy (S.Cons (ONE t, ts)) ;; let rec unconsTree = function | (lazy S.Nil) -> raise Empty | (lazy (S.Cons (ONE t, lazy S.Nil))) -> (t, lazy S.Nil) | (lazy (S.Cons (ONE t, ts))) -> (t, (lazy (S.Cons (ZERO, ts)))) | (lazy (S.Cons (ZERO, ts))) -> let (NODE (_, t1, t2), ts') = unconsTree ts in (t1, lazy (S.Cons (ONE t2, ts'))) ;;
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. type 'a tree = LEAF of 'a | NODE of int * 'a tree * 'a tree type 'a digit = ZERO | ONE of 'a tree | TWO of 'a tree * 'a tree type rlist = Elem.t digit S.stream let rec consTree = function | (t, lazy S.Nil) -> lazy (S.Cons (ONE t, lazy S.Nil)) | (t1, lazy (S.Cons (TWO (t2, t3), ts))) -> lazy (S.Cons (ONE t1, consTree (link (t2, t3), ts))) | (t1, lazy (S.Cons (ONE t2, ts))) -> lazy (S.Cons (TWO (t1, t2), ts)) | (t, lazy (S.Cons (ZERO, ts))) -> lazy (S.Cons (ONE t, ts)) ;; let rec unconsTree = function | (lazy S.Nil) -> raise Empty | (lazy (S.Cons (TWO (t1, t2), ts))) -> (t1, lazy (S.Cons (ONE t2, ts))) | (lazy (S.Cons (ONE t, lazy S.Nil))) -> (t, lazy S.Nil) | (lazy (S.Cons (ONE t, ts))) -> (t, (lazy (S.Cons (ZERO, ts)))) | (lazy (S.Cons (ZERO, ts))) -> let (NODE (_, t1, t2), ts') = unconsTree ts in (t1, lazy (S.Cons (ONE t2, ts'))) ;;
  • 14.
  • 15.